commit c5f17bd3dc9aeb99a9a95b0854807e7743a5d07a
parent 96af28da605a7c6a9f30f047af3686d1a9e09aad
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Fri, 14 Feb 2014 14:52:04 +0100
remove some signed / unsigned type warnings
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
Diffstat:
5 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/chvt.c b/chvt.c
@@ -28,7 +28,8 @@ usage(void)
int
main(int argc, char *argv[])
{
- int n, i, fd;
+ unsigned int n, i;
+ int fd;
char c;
if(argc!=2 || strspn(argv[1], "1234567890") != strlen(argv[1]))
diff --git a/dmesg.c b/dmesg.c
@@ -84,6 +84,7 @@ dmesg_show(int fd, const void *buf, size_t n)
int last = '\n';
char newbuf[n], *q = newbuf;
const char *p = buf;
+ ssize_t r;
size_t i;
memset(newbuf, 0, n);
@@ -97,7 +98,8 @@ dmesg_show(int fd, const void *buf, size_t n)
}
last = p[i++];
}
- if (write(fd, newbuf, n) != n)
+ r = write(fd, newbuf, n);
+ if(r < 0 || (size_t)r != n)
return -1;
if (last != '\n')
if (write(fd, "\n", 1) != 1)
diff --git a/getty.c b/getty.c
@@ -27,7 +27,7 @@ main(int argc, char *argv[])
struct sigaction sa;
char term[128], logname[LOGIN_NAME_MAX], c;
char hostname[HOST_NAME_MAX + 1];
- int i = 0;
+ unsigned int i = 0;
ssize_t n;
ARGBEGIN {
diff --git a/insmod.c b/insmod.c
@@ -18,7 +18,7 @@ int
main(int argc, char *argv[])
{
char *buf = NULL, *opts = NULL;
- unsigned long blen, plen = 0;
+ size_t blen, plen = 0;
int i, fd;
ssize_t n;
struct stat sb;
@@ -36,12 +36,12 @@ main(int argc, char *argv[])
eprintf("open %s:", argv[0]);
if (fstat(fd, &sb) < 0)
eprintf("stat %s:", argv[0]);
- buf = malloc(sb.st_size);
- if (!buf)
- eprintf("malloc:");
blen = sb.st_size;
+ if(!(buf = malloc(blen)))
+ eprintf("malloc:");
- if ((n = read(fd, buf, blen)) != blen)
+ n = read(fd, buf, blen);
+ if(n < 0 || (size_t)n != blen)
eprintf("read:");
argc--;
@@ -51,9 +51,8 @@ main(int argc, char *argv[])
plen += strlen(argv[i]);
if (plen > 0) {
plen += argc;
- opts = calloc(1, plen);
- if (!opts)
- eprintf("malloc:");
+ if(!(opts = calloc(1, plen)))
+ eprintf("calloc:");
for (i = 0; i < argc; i++) {
strcat(opts, argv[i]);
if (i + 1 < argc)
diff --git a/util/proc.c b/util/proc.c
@@ -51,7 +51,7 @@ parsestat(pid_t pid, struct procstat *ps)
&ps->sid, &ps->tty_nr, &ps->tpgid, &ps->flags,
&ps->minflt, &ps->cminflt, &ps->majflt, &ps->cmajflt,
&ps->utime, &ps->stime);
- fscanf(fp, "%ld %ld %ld %ld %ld %ld %lld %lu %ld %ld",
+ fscanf(fp, "%ld %ld %ld %ld %ld %ld %llu %lu %ld %ld",
&ps->cutime, &ps->cstime, &ps->priority, &ps->nice,
&ps->num_threads, &ps->itrealvalue, &ps->starttime,
&ps->vsize, &ps->rss, &ps->rsslim);