[patch] 1.11.0.svn: compiler warnings when building for i386 arch

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Mon May 12 21:50:32 UTC 2008


On Mon, 12 May 2008, Denys Vlasenko wrote:

> Patch is applied with minor corrections, thanks.

Sorry, but I'm a bit confused.  After synchning with svn i still find some
26 files not being touched :(

I may be missing something or you may not have seen those.  Attaching
another diff.


Cheers,

-- 
Cristian
-------------- next part --------------
Index: debianutils/start_stop_daemon.c
===================================================================
--- debianutils/start_stop_daemon.c	(revision 21945)
+++ debianutils/start_stop_daemon.c	(working copy)
@@ -126,7 +126,7 @@
 	sprintf(buf, "/proc/%u", pid);
 	if (stat(buf, &sb) != 0)
 		return 0;
-	return (sb.st_uid == user_id);
+	return (sb.st_uid == (__uid_t)user_id);
 }
 
 static int pid_is_cmd(pid_t pid)
Index: coreutils/basename.c
===================================================================
--- coreutils/basename.c	(revision 21620)
+++ coreutils/basename.c	(working copy)
@@ -48,5 +48,5 @@
 
 	/* puts(s) will do, but we can do without stdio this way: */
 	s[m++] = '\n';
-	return full_write(STDOUT_FILENO, s, m) == m;
+	return full_write(STDOUT_FILENO, s, m) == (ssize_t)m;
 }
Index: coreutils/dd.c
===================================================================
--- coreutils/dd.c	(revision 21848)
+++ coreutils/dd.c	(working copy)
@@ -65,7 +65,7 @@
 	ssize_t n = full_write_or_warn(buf, len, filename);
 	if (n < 0)
 		return 1;
-	if (n == obs)
+	if ((size_t)n == obs)
 		G.out_full++;
 	else if (n) /* > 0 */
 		G.out_part++;
@@ -312,7 +312,7 @@
 			while (n) {
 				size_t d = obs - oc;
 
-				if (d > n)
+				if (d > (size_t)n)
 					d = n;
 				memcpy(obuf + oc, tmp, d);
 				n -= d;
Index: coreutils/test.c
===================================================================
--- coreutils/test.c	(revision 21798)
+++ coreutils/test.c	(working copy)
@@ -412,7 +412,7 @@
 static int filstat(char *nm, enum token mode)
 {
 	struct stat s;
-	int i = i; /* gcc 3.x thinks it can be used uninitialized */
+	unsigned int i = i; /* gcc 3.x thinks it can be used uninitialized */
 
 	if (mode == FILSYM) {
 #ifdef S_IFLNK
Index: coreutils/tr.c
===================================================================
--- coreutils/tr.c	(revision 21962)
+++ coreutils/tr.c	(working copy)
@@ -219,7 +219,7 @@
 
 	for (;;) {
 		/* If we're out of input, flush output and read more input. */
-		if (in_index == read_chars) {
+		if ((ssize_t)in_index == read_chars) {
 			if (out_index) {
 				xwrite(STDOUT_FILENO, (char *)output, out_index);
 				out_index = 0;
Index: coreutils/sort.c
===================================================================
--- coreutils/sort.c	(revision 21509)
+++ coreutils/sort.c	(working copy)
@@ -59,7 +59,8 @@
 
 static char *get_key(char *str, struct sort_key *key, int flags)
 {
-	int start = 0, end = 0, len, i, j;
+	int start = 0, end = 0, len, j;
+	unsigned int i;
 
 	/* Special case whole string, so we don't have to make a copy */
 	if (key->range[0] == 1 && !key->range[1] && !key->range[2] && !key->range[3]
Index: coreutils/stty.c
===================================================================
--- coreutils/stty.c	(revision 21043)
+++ coreutils/stty.c	(working copy)
@@ -710,7 +710,7 @@
 {
 	char buf[128];
 	va_list args;
-	int buflen;
+	unsigned int buflen;
 
 	va_start(args, message);
 	buflen = vsnprintf(buf, sizeof(buf), message, args);
Index: coreutils/tail.c
===================================================================
--- coreutils/tail.c	(revision 21457)
+++ coreutils/tail.c	(working copy)
@@ -92,7 +92,8 @@
 	size_t tailbufsize;
 	int taillen = 0;
 	int newlines_seen = 0;
-	int nfiles, nread, nwrite, seen, i, opt;
+	int nfiles, nread, nwrite, i, opt;
+	unsigned int seen;
 
 	int *fds;
 	char *s, *buf;
@@ -210,7 +211,7 @@
 			} else if (count) {
 				if (COUNT_BYTES) {
 					taillen += nread;
-					if (taillen > count) {
+					if (taillen > (int)count) {
 						memmove(tailbuf, tailbuf + taillen - count, count);
 						taillen = count;
 					}
@@ -225,7 +226,7 @@
 						}
 					} while (k);
 
-					if (newlines_seen + newlines_in_buf < count) {
+					if (newlines_seen + newlines_in_buf < (int)count) {
 						newlines_seen += newlines_in_buf;
 						taillen += nread;
 					} else {
@@ -243,7 +244,7 @@
 						memmove(tailbuf, s, taillen);
 						newlines_seen = count - extra;
 					}
-					if (tailbufsize < taillen + BUFSIZ) {
+					if (tailbufsize < (size_t)taillen + BUFSIZ) {
 						tailbufsize = taillen + BUFSIZ;
 						tailbuf = xrealloc(tailbuf, tailbufsize);
 					}
Index: coreutils/expand.c
===================================================================
--- coreutils/expand.c	(revision 21370)
+++ coreutils/expand.c	(working copy)
@@ -41,7 +41,7 @@
 	char *line;
 	char *ptr;
 	int convert;
-	int pos;
+	unsigned int pos;
 
 	/* Increment tab_size by 1 locally.*/
 	tab_size++;
@@ -80,7 +80,7 @@
 	int convert;
 	int pos;
 	int i = 0;
-	int column = 0;
+	unsigned int column = 0;
 
 	while ((line = xmalloc_fgets(file)) != NULL) {
 		convert = 1;
Index: coreutils/cut.c
===================================================================
--- coreutils/cut.c	(revision 21509)
+++ coreutils/cut.c	(working copy)
@@ -64,7 +64,7 @@
 			/* print the chars specified in each cut list */
 			for (; cl_pos < nlists; cl_pos++) {
 				spos = cut_lists[cl_pos].startpos;
-				while (spos < strlen(line)) {
+				while (spos < (int)strlen(line)) {
 					if (!printed[spos]) {
 						printed[spos] = 'X';
 						putchar(line[spos]);
@@ -80,12 +80,12 @@
 
 			/* get out if we have no more lists to process or if the lines
 			 * are lower than what we're interested in */
-			if (linenum < spos || cl_pos >= nlists)
+			if (((int)linenum < spos) || (cl_pos >= nlists))
 				goto next_line;
 
 			/* if the line we're looking for is lower than the one we were
 			 * passed, it means we displayed it already, so move on */
-			while (spos < linenum) {
+			while (spos < (int)linenum) {
 				spos++;
 				/* go to the next list if we're at the end of this one */
 				if (spos > cut_lists[cl_pos].endpos
@@ -97,7 +97,7 @@
 					spos = cut_lists[cl_pos].startpos;
 					/* get out if the current line is lower than the one
 					 * we just became interested in */
-					if (linenum < spos)
+					if ((int)linenum < spos)
 						goto next_line;
 				}
 			}
Index: libbb/read.c
===================================================================
--- libbb/read.c	(revision 21785)
+++ libbb/read.c	(working copy)
@@ -111,7 +111,7 @@
 {
 	if (count) {
 		ssize_t size = full_read(fd, buf, count);
-		if (size != count)
+		if (size - count != 0)
 			bb_error_msg_and_die("short read");
 	}
 }
@@ -160,7 +160,7 @@
 
 	goto jump_in;
 	while (sz < maxsz) {
-		if (p - buf == sz) {
+		if (p - buf - sz == 0) {
  jump_in:
 			buf = xrealloc(buf, sz + 128);
 			p = buf + sz;
Index: libbb/md5.c
===================================================================
--- libbb/md5.c	(revision 21538)
+++ libbb/md5.c	(working copy)
@@ -383,7 +383,7 @@
 	// Process all input.
 
 	while (len) {
-		int i = 64 - ctx->buflen;
+		unsigned int i = 64 - ctx->buflen;
 
 		// Copy data into aligned buffer.
 
Index: libbb/xfuncs_printf.c
===================================================================
--- libbb/xfuncs_printf.c	(revision 21798)
+++ libbb/xfuncs_printf.c	(working copy)
@@ -204,7 +204,7 @@
 {
 	if (count) {
 		ssize_t size = full_write(fd, buf, count);
-		if (size != count)
+		if (size - count != 0)
 			bb_error_msg_and_die("short write");
 	}
 }
Index: libbb/lineedit.c
===================================================================
--- libbb/lineedit.c	(revision 21872)
+++ libbb/lineedit.c	(working copy)
@@ -262,7 +262,7 @@
 		return;
 	cursor -= num;
 
-	if (cmdedit_x >= num) {
+	if ((unsigned)cmdedit_x >= num) {
 		cmdedit_x -= num;
 		if (num <= 4) {
 			/* This is longer by 5 bytes on x86.
@@ -321,7 +321,7 @@
 {
 	int j = cursor;
 
-	if (j == command_len)
+	if (j == (int)command_len)
 		return;
 
 #if ENABLE_FEATURE_EDITING_VI
@@ -830,7 +830,7 @@
 
 	if (!*lastWasTab) {
 		char *tmp, *tmp1;
-		int len_found;
+		size_t len_found;
 /*		char matchBuf[MAX_LINELEN]; */
 #define matchBuf (S.input_tab__matchBuf)
 		int find_type;
@@ -1787,7 +1787,7 @@
 			if (vi_cmdmode)  /* Don't self-insert */
 				break;
 #endif
-			if (command_len >= (maxsize - 2))        /* Need to leave space for enter */
+			if ((int)command_len >= (maxsize - 2))        /* Need to leave space for enter */
 				break;
 
 			command_len++;
Index: libbb/u_signal_names.c
===================================================================
--- libbb/u_signal_names.c	(revision 21043)
+++ libbb/u_signal_names.c	(working copy)
@@ -130,7 +130,7 @@
 		return i;
 	if (strncasecmp(name, "SIG", 3) == 0)
 		name += 3;
-	for (i = 0; i < ARRAY_SIZE(signals); i++)
+	for (i = 0; (size_t)i < ARRAY_SIZE(signals); i++)
 		if (strcasecmp(name, signals[i]) == 0)
 			return i;
 
@@ -172,7 +172,7 @@
 {
 	int signo;
 
-	for (signo = 1; signo < ARRAY_SIZE(signals); signo++) {
+	for (signo = 1; (size_t)signo < ARRAY_SIZE(signals); signo++) {
 		const char *name = signals[signo];
 		if (name[0])
 			puts(name);
Index: miscutils/crond.c
===================================================================
--- miscutils/crond.c	(revision 21668)
+++ miscutils/crond.c	(working copy)
@@ -145,7 +145,7 @@
 	int level = (ctl[0] & 0x1f);
 
 	va_start(va, ctl);
-	if (level >= LogLevel) {
+	if (level >= (int)LogLevel) {
 		/* Debug mode: all to (non-redirected) stderr, */
 		/* Syslog mode: all to syslog (logmode = LOGMODE_SYSLOG), */
 		if (!DebugOpt && LogFile) {
@@ -423,7 +423,7 @@
 
 static void FixDayDow(CronLine *line)
 {
-	int i;
+	size_t i;
 	int weekUsed = 0;
 	int daysUsed = 0;
 
Index: miscutils/eject.c
===================================================================
--- miscutils/eject.c	(revision 21974)
+++ miscutils/eject.c	(working copy)
@@ -38,7 +38,7 @@
 		{ START_STOP, 0, 0, 0, 2, 0 }
 	};
 
-	int i;
+	unsigned int i;
 	unsigned char sense_buffer[32];
 	unsigned char inqBuff[2];
 	sg_io_hdr_t io_hdr;
Index: findutils/xargs.c
===================================================================
--- findutils/xargs.c	(revision 21370)
+++ findutils/xargs.c	(working copy)
@@ -233,7 +233,7 @@
 		}
 		if (s == NULL)
 			s = p = buf;
-		if ((p - buf) >= mc)
+		if (p - buf -mc >= 0)
 			bb_error_msg_and_die("argument line too long");
 		*p++ = (c == EOF ? '\0' : c);
 		if (c == EOF) { /* word's delimiter or EOF detected */
Index: editors/vi.c
===================================================================
--- editors/vi.c	(revision 21931)
+++ editors/vi.c	(working copy)
@@ -2239,7 +2239,8 @@
 			pfd[0].events = POLLIN;
 			// keep reading while there are input chars, and room in buffer
 			// for a complete ESC sequence (assuming 8 chars is enough)
-			while (safe_poll(pfd, 1, 0) > 0 && n <= (sizeof(readbuffer) - 8)) {
+			while ((safe_poll(pfd, 1, 0) > 0)
+			       && ((size_t)n <= (sizeof(readbuffer) - 8))) {
 				// read the rest of the ESC string
 				int r = safe_read(0, readbuffer + n, sizeof(readbuffer) - n);
 				if (r > 0)
Index: editors/awk.c
===================================================================
--- editors/awk.c	(revision 21284)
+++ editors/awk.c	(working copy)
@@ -676,7 +676,7 @@
 	return c;
 }
 
-static int ALWAYS_INLINE isalnum_(int c)
+static ALWAYS_INLINE int isalnum_(int c)
 {
 	return (isalnum(c) || c == '_');
 }
@@ -1682,7 +1682,7 @@
 {
 	char **w;
 	hash_item *hi;
-	int i;
+	unsigned int i;
 
 	if (v->type & VF_WALK)
 		free(v->x.walker);
@@ -1996,7 +1996,7 @@
 	}
 
 	nargs = i;
-	if (nargs < (info >> 30))
+	if ((uint32_t)nargs < (info >> 30))
 		syntax_error(EMSG_TOO_FEW_ARGS);
 
 	switch (info & OPNMASK) {
Index: editors/sed.c
===================================================================
--- editors/sed.c	(revision 21509)
+++ editors/sed.c	(working copy)
@@ -628,7 +628,7 @@
 {
 	char *oldline = *line;
 	int altered = 0;
-	int match_count = 0;
+	unsigned int match_count = 0;
 	regex_t *current_regex;
 
 	/* Handle empty regex. */
@@ -665,7 +665,8 @@
 
 		/* If we aren't interested in this match, output old line to
 		   end of match and continue */
-		if (sed_cmd->which_match && sed_cmd->which_match != match_count) {
+		if (sed_cmd->which_match
+		    && (sed_cmd->which_match != match_count)) {
 			for (i = 0; i < G.regmatch[0].rm_eo; i++)
 				pipe_putc(*oldline++);
 			continue;
Index: util-linux/volume_id/util.c
===================================================================
--- util-linux/volume_id/util.c	(revision 21370)
+++ util-linux/volume_id/util.c	(working copy)
@@ -212,7 +212,7 @@
 			}
 			dbg("got 0x%zx (%zi) bytes", buf_len, buf_len);
 			id->sbbuf_len = buf_len;
-			if (buf_len < off + len) {
+			if ((uint64_t)buf_len < off + (uint64_t)len) {
 				dbg("requested 0x%zx bytes, got only 0x%zx bytes", len, buf_len);
 				return NULL;
 			}
@@ -243,7 +243,7 @@
 		dbg("got 0x%zx (%zi) bytes", buf_len, buf_len);
 		id->seekbuf_off = off;
 		id->seekbuf_len = buf_len;
-		if (buf_len < len) {
+		if ((size_t)buf_len < len) {
 			dbg("requested 0x%zx bytes, got only 0x%zx bytes", len, buf_len);
 			return NULL;
 		}
Index: util-linux/volume_id/volume_id.c
===================================================================
--- util-linux/volume_id/volume_id.c	(revision 21370)
+++ util-linux/volume_id/volume_id.c	(working copy)
@@ -152,7 +152,7 @@
 
 int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size)
 {
-	int i;
+	size_t i;
 
 	if (id == NULL)
 		return -EINVAL;
Index: util-linux/mount.c
===================================================================
--- util-linux/mount.c	(revision 21974)
+++ util-linux/mount.c	(working copy)
@@ -307,7 +307,7 @@
 
 	// Loop through options
 	for (;;) {
-		int i;
+		size_t i;
 		char *comma = strchr(options, ',');
 		const char *option_str = mount_option_str;
 
@@ -1004,7 +1004,8 @@
 			bb_herror_msg("%s", hostname);
 			goto fail;
 		}
-		if (hp->h_length > sizeof(struct in_addr)) {
+		if ((hp->h_length < 0)
+		    || ((size_t)hp->h_length > sizeof(struct in_addr))) {
 			bb_error_msg("got bad hp->h_length");
 			hp->h_length = sizeof(struct in_addr);
 		}
@@ -1280,7 +1281,8 @@
 				bb_herror_msg("%s", mounthost);
 				goto fail;
 			} else {
-				if (hp->h_length > sizeof(struct in_addr)) {
+				if ((hp->h_length < 0)
+				    || ((size_t)hp->h_length > sizeof(struct in_addr))) {
 					bb_error_msg("got bad hp->h_length?");
 					hp->h_length = sizeof(struct in_addr);
 				}
Index: util-linux/switch_root.c
===================================================================
--- util-linux/switch_root.c	(revision 21370)
+++ util-linux/switch_root.c	(working copy)
@@ -92,9 +92,9 @@
 	// from all the people who WILL eat their filesystems.)
 
 	if (lstat("/init", &st1) || !S_ISREG(st1.st_mode) || statfs("/", &stfs) ||
-		(stfs.f_type != RAMFS_MAGIC && stfs.f_type != TMPFS_MAGIC) ||
-		getpid() != 1)
-	{
+	    (((unsigned int)stfs.f_type != RAMFS_MAGIC)
+	     && ((unsigned int)stfs.f_type != TMPFS_MAGIC))
+	    || (getpid() != 1)) {
 		bb_error_msg_and_die("not rootfs");
 	}
 
Index: util-linux/mdev.c
===================================================================
--- util-linux/mdev.c	(revision 21959)
+++ util-linux/mdev.c	(working copy)
@@ -120,7 +120,8 @@
 
 				/* If not this device, skip rest of line */
 				/* (regexec returns whole pattern as "range" 0) */
-				if (result || off[0].rm_so || off[0].rm_eo != strlen(device_name))
+				if (result || off[0].rm_so
+				    || (off[0].rm_eo != (regoff_t)strlen(device_name)))
 					goto next_line;
 			}
 


More information about the busybox mailing list