From 96ab979e7a7e234ab3a1238619328e97569f3eab Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Mon, 4 Jan 2021 17:23:11 -0800 Subject: [PATCH] Change lisp_string_to_c_string length parameter to be size_t (#179) The argument passed to the length parameter of lisp_string_to_c_string is always the sizeof an array, and since it is compared to the Lisp unsigned length of the Lisp string is more appropriately a size_t than an int. Likewise for the index into a string. --- inc/uutilsdefs.h | 2 +- src/uutils.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/uutilsdefs.h b/inc/uutilsdefs.h index 2100328..92b6c06 100644 --- a/inc/uutilsdefs.h +++ b/inc/uutilsdefs.h @@ -1,6 +1,6 @@ #ifndef UUTILSDEFS_H #define UUTILSDEFS_H 1 -int lisp_string_to_c_string(LispPTR Lisp, char *C, int length); +int lisp_string_to_c_string(LispPTR Lisp, char *C, size_t length); int c_string_to_lisp_string(char *C, LispPTR Lisp); LispPTR check_unix_password(LispPTR *args); LispPTR unix_username(LispPTR *args); diff --git a/src/uutils.c b/src/uutils.c index 119d440..3b33233 100644 --- a/src/uutils.c +++ b/src/uutils.c @@ -50,7 +50,7 @@ /* */ /************************************************************************/ -int lisp_string_to_c_string(LispPTR Lisp, char *C, int length) { +int lisp_string_to_c_string(LispPTR Lisp, char *C, size_t length) { register OneDArray *arrayp; register char *base; @@ -95,7 +95,7 @@ int lisp_string_to_c_string(LispPTR Lisp, char *C, int length) { int c_string_to_lisp_string(char *C, LispPTR Lisp) { register OneDArray *arrayp; char *base; - register int length; + register size_t length; length = strlen(C); if (GetTypeNumber(Lisp) != TYPE_ONED_ARRAY) { return (-1); } @@ -111,7 +111,7 @@ int c_string_to_lisp_string(char *C, LispPTR Lisp) { strcpy(base, C); #else { - register int i; + register size_t i; register char *dp; for (i = 0, dp = C; i < length + 1; i++) { int ch = *dp++;