diff --git a/doc/Changelog b/doc/Changelog index 69fd0f1..ddf1b6a 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -7,6 +7,7 @@ sysvinit (2.88dsf) UNRELEASED; urgency=low before files are copied into them. * Fix minor bug in optimizing of argument parsing. Based on report from jakemus on freshmeat. + * Add casts to get rid of compiler warning about signed/unsigned issues. -- Petter Reinholdtsen Sun, 12 Jul 2009 19:58:10 +0200 diff --git a/src/bootlogd.c b/src/bootlogd.c index d9be60b..25bc49f 100644 --- a/src/bootlogd.c +++ b/src/bootlogd.c @@ -135,7 +135,7 @@ int findtty(char *res, int rlen, dev_t dev) fprintf(stderr, "bootlogd: cannot find console device " "%d:%d in /dev\n", major(dev), minor(dev)); r = -1; - } else if (strlen(ent->d_name) + 5 >= rlen) { + } else if ((int)strlen(ent->d_name) + 5 >= rlen) { fprintf(stderr, "bootlogd: console device name too long\n"); r = -1; } else @@ -351,7 +351,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len) break; case '\t': line.pos += (line.pos / 8 + 1) * 8; - if (line.pos >= sizeof(line.buf)) + if (line.pos >= (int)sizeof(line.buf)) line.pos = sizeof(line.buf) - 1; break; case 32 ... 127: @@ -367,7 +367,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len) len--; tlen = strlen(tmp); - if (tlen && (line.pos + tlen < sizeof(line.buf))) { + if (tlen && (line.pos + tlen < (int)sizeof(line.buf))) { memcpy(line.buf + line.pos, tmp, tlen); line.pos += tlen; } @@ -640,7 +640,7 @@ int main(int argc, char **argv) else todo = endptr - outptr; if (fp && todo) - writelog(fp, outptr, todo); + writelog(fp, (unsigned char *)outptr, todo); } if (fp) { diff --git a/src/hddown.c b/src/hddown.c index 89e9f47..a8e394a 100644 --- a/src/hddown.c +++ b/src/hddown.c @@ -111,11 +111,11 @@ static char *list_disks(DIR* blk, unsigned int* flags) } ret = snprintf(buf, sizeof(buf), SYS_BLK "/%s/device", d->d_name); - if ((ret >= sizeof(buf)) || (ret < 0)) + if ((ret >= (int)sizeof(buf)) || (ret < 0)) goto empty; /* error */ ret = readlink(buf, lnk, sizeof(lnk)); - if (ret >= sizeof(lnk)) + if (ret >= (int)sizeof(lnk)) goto empty; /* error */ if (ret < 0) { if (errno != ENOENT) @@ -129,7 +129,7 @@ static char *list_disks(DIR* blk, unsigned int* flags) continue; /* should not happen */ ret = snprintf(buf, sizeof(buf), SYS_CLASS "/%s/manage_start_stop", ptr); - if ((ret >= sizeof(buf)) || (ret < 0)) + if ((ret >= (int)sizeof(buf)) || (ret < 0)) goto empty; /* error */ ret = stat(buf, &st); @@ -200,7 +200,7 @@ static int do_standby_idedisk(char *device, unsigned int flags) int fd, ret; ret = snprintf(buf, sizeof(buf), DEV_BASE "/%s", device); - if ((ret >= sizeof(buf)) || (ret < 0)) + if ((ret >= (int)sizeof(buf)) || (ret < 0)) return -1; if ((fd = open(buf, O_RDWR)) < 0) @@ -271,7 +271,7 @@ static FILE *hdopen(const char* const format, const char* const name) int fd, ret; ret = snprintf(buf, sizeof(buf), format, name); - if ((ret >= sizeof(buf)) || (ret < 0)) + if ((ret >= (int)sizeof(buf)) || (ret < 0)) goto error; /* error */ fd = open(buf, O_RDONLY|O_NOCTTY); @@ -324,7 +324,7 @@ static int flush_cache_ext(const char *device) goto out; /* small disk */ ret = snprintf(buf, sizeof(buf), DEV_BASE "/%s", device); - if ((ret >= sizeof(buf)) || (ret < 0)) + if ((ret >= (int)sizeof(buf)) || (ret < 0)) return -1; /* error */ if ((fd = open(buf, O_RDONLY|O_NONBLOCK)) < 0) diff --git a/src/init.c b/src/init.c index 7a05435..74bccae 100644 --- a/src/init.c +++ b/src/init.c @@ -1254,7 +1254,7 @@ void read_inittab(void) strncpy(ch->id, id, sizeof(utproto.ut_id) + 1); /* Hack for different libs. */ strncpy(ch->process, process, sizeof(ch->process) - 1); if (rlevel[0]) { - for(f = 0; f < sizeof(rlevel) - 1 && rlevel[f]; f++) { + for(f = 0; f < (int)sizeof(rlevel) - 1 && rlevel[f]; f++) { ch->rlevel[f] = rlevel[f]; if (ch->rlevel[f] == 's') ch->rlevel[f] = 'S'; } diff --git a/src/last.c b/src/last.c index 5bf48ec..38d23ff 100644 --- a/src/last.c +++ b/src/last.c @@ -331,7 +331,7 @@ int dns_lookup(char *result, int size, int useip, int32_t *a) * * Ugly. */ - if (a[0] == 0 && a[1] == 0 && a[2] == htonl (0xffff)) + if (a[0] == 0 && a[1] == 0 && a[2] == (int32_t)htonl (0xffff)) mapped = 1; topnibble = ntohl((unsigned int)a[0]) >> 28; @@ -462,7 +462,7 @@ int list(struct utmp *p, time_t t, int what) r = dns_lookup(domain, sizeof(domain), useip, p->ut_addr_v6); if (r < 0) { len = UT_HOSTSIZE; - if (len >= sizeof(domain)) len = sizeof(domain) - 1; + if (len >= (int)sizeof(domain)) len = sizeof(domain) - 1; domain[0] = 0; strncat(domain, p->ut_host, len); } diff --git a/src/shutdown.c b/src/shutdown.c index e96b3a6..a950209 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -150,7 +150,7 @@ int init_setenv(char *name, char *value) nl = strlen(name); vl = value ? strlen(value) : 0; - if (nl + vl + 3 >= sizeof(request.i.data)) + if (nl + vl + 3 >= (int)sizeof(request.i.data)) return -1; memcpy(request.i.data, name, nl); diff --git a/src/sulogin.c b/src/sulogin.c index dcc049b..2540729 100644 --- a/src/sulogin.c +++ b/src/sulogin.c @@ -298,7 +298,7 @@ char *getpasswd(char *crypted) if (read(0, pass, sizeof(pass) - 1) <= 0) ret = NULL; else { - for(i = 0; i < sizeof(pass) && pass[i]; i++) + for(i = 0; i < (int)sizeof(pass) && pass[i]; i++) if (pass[i] == '\r' || pass[i] == '\n') { pass[i] = 0; break;