From: Matthew Fernandez Date: Sat, 18 Sep 2021 01:37:57 +0000 (-0700) Subject: lefty SFstatAndCheck: use 'size_t' variables when dealing with buffer sizes X-Git-Tag: 2.49.1~6^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53f5721d84e9f6d043bd34ff756d455601d92fd7;p=graphviz lefty SFstatAndCheck: use 'size_t' variables when dealing with buffer sizes Squashes two -Wconversion warnings and improves portability. --- diff --git a/cmd/lefty/ws/x11/libfilereq/Draw.c b/cmd/lefty/ws/x11/libfilereq/Draw.c index 9d79eaf62..9bd1448d5 100644 --- a/cmd/lefty/ws/x11/libfilereq/Draw.c +++ b/cmd/lefty/ws/x11/libfilereq/Draw.c @@ -38,6 +38,7 @@ */ #include "config.h" +#include #include #include #include "SFinternal.h" @@ -200,21 +201,20 @@ static void SFdeleteEntry (SFDir *dir, SFEntry *entry) { ); } -static void SFwriteStatChar (char *name, int last, struct stat *statBuf) { +static void SFwriteStatChar(char *name, size_t last, struct stat *statBuf) { name[last] = SFstatChar (statBuf); } static int SFstatAndCheck (SFDir *dir, SFEntry *entry) { struct stat statBuf; char save; - int last; /* must be restored before returning */ save = *(dir->path); *(dir->path) = 0; if (!SFchdir (SFcurrentPath)) { - last = strlen (entry->real) - 1; + size_t last = strlen(entry->real) - 1; entry->real[last] = 0; entry->statDone = 1; if ( @@ -229,9 +229,7 @@ static int SFstatAndCheck (SFDir *dir, SFEntry *entry) { shown = NULL; if (SFfunc (entry->real, &shown, &statBuf)) { if (shown) { - int len; - - len = strlen (shown); + size_t len = strlen(shown); entry->shown = XtMalloc ((unsigned) (len + 2)); strcpy (entry->shown, shown); SFwriteStatChar (entry->shown, len, &statBuf);