diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-09-17 09:11:05 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-09-17 09:11:05 -0700 |
commit | 0db44a83b2bb9b74a266d41e8b7d2731713d7eac (patch) | |
tree | ad38eb39ade86232c0b43a0d53d27ca12ddd2c34 | |
parent | 793d9d83620c50308f128e0a635224a2fbb14a62 (diff) |
Fix -Wsign-compare warnings
imake.c: In function ‘ask_sun_compiler_for_versions’:
imake.c:1200:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (len < sizeof(cmdtorun)) {
^
imake.c: In function ‘get_gcc’:
imake.c:1380:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < sizeof (gcc_path) / sizeof gcc_path[0]; i++) {
^
imake.c: In function ‘writetmpfile’:
imake.c:2027:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (fwrite(buf, sizeof(char), cnt, fd) == -1)
^~
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | imake.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -346,7 +346,7 @@ void cppit(const char *imakefile, const char *template, const char *masterc, void makeit(void); void CleanCppOutput(FILE *tmpfd, const char *tmpfname); boolean isempty(char *line); -void writetmpfile(FILE *fd, const char *buf, int cnt, const char *fname); +void writetmpfile(FILE *fd, const char *buf, size_t cnt, const char *fname); #ifdef SIGNALRETURNSINT int catch(int sig); #else @@ -442,12 +442,12 @@ void showit(FILE *fd) { char buf[ BUFSIZ ]; - int red; + size_t red; fseek(fd, 0, SEEK_SET); while ((red = fread(buf, 1, BUFSIZ, fd)) > 0) writetmpfile(stdout, buf, red, "stdout"); - if (red < 0) + if (ferror(fd)) LogFatal("Cannot read %s.", tmpMakefile); } @@ -1191,7 +1191,7 @@ ask_sun_compiler_for_versions(const char *cmd, const char *path, const char vflag[] = " -V 2>&1"; int retval = -1; - int len = strlen(cmd) + sizeof(vflag); + size_t len = strlen(cmd) + sizeof(vflag); if (path != NULL) { len += strlen(path) + 1; @@ -1363,7 +1363,7 @@ get_gcc(char *cmd) }; if (CrossCompiling) { - int i; + unsigned int i; for (i = 0; i < sizeof (cross_cc_name) / sizeof cross_cc_name[0]; i++){ strcpy (cmd, CrossCompileDir); strcat (cmd, "/"); @@ -1376,7 +1376,7 @@ get_gcc(char *cmd) } else #endif { - int i; + unsigned int i; for (i = 0; i < sizeof (gcc_path) / sizeof gcc_path[0]; i++) { if (lstat (gcc_path[i], &sb) == 0) { strcpy (cmd, gcc_path[i]); @@ -2022,9 +2022,9 @@ ReadLine(FILE *tmpfd, const char *tmpfname) } void -writetmpfile(FILE *fd, const char *buf, int cnt, const char *fname) +writetmpfile(FILE *fd, const char *buf, size_t cnt, const char *fname) { - if (fwrite(buf, sizeof(char), cnt, fd) == -1) + if (fwrite(buf, sizeof(char), cnt, fd) < cnt) LogFatal("Cannot write to %s.", fname); } |