[hackers] [ubase] remove some signed / unsigned type warnings || Hiltjo Posthuma
commit c5f17bd3dc9aeb99a9a95b0854807e7743a5d07a
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Fri Feb 14 14:52:04 2014 +0100
remove some signed / unsigned type warnings
Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
diff --git a/chvt.c b/chvt.c
index a56b4b0..d1e604c 100644
--- a/chvt.c
+++ b/chvt.c
_AT_@ -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
index 35a36ba..d86f56b 100644
--- a/dmesg.c
+++ b/dmesg.c
_AT_@ -84,6 +84,7 @@ dmesg_show(int fd, const void *buf, size_t n)
int last = '
';
char newbuf[n], *q = newbuf;
const char *p = buf;
+ ssize_t r;
size_t i;
memset(newbuf, 0, n);
_AT_@ -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 != '
')
if (write(fd, "
", 1) != 1)
diff --git a/getty.c b/getty.c
index 33fb450..75b20b6 100644
--- a/getty.c
+++ b/getty.c
_AT_@ -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
index 730b71a..c5c1c0b 100644
--- a/insmod.c
+++ b/insmod.c
_AT_@ -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;
_AT_@ -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--;
_AT_@ -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
index 3b32a7b..fa968e7 100644
--- a/util/proc.c
+++ b/util/proc.c
_AT_@ -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);
Received on Fri Feb 14 2014 - 15:11:41 CET
This archive was generated by hypermail 2.3.0
: Fri Feb 14 2014 - 15:12:36 CET