1
0
mirror of git://git.suckless.org/ubase synced 2024-12-24 23:52:34 +00:00

remove some signed / unsigned type warnings

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
This commit is contained in:
Hiltjo Posthuma 2014-02-14 14:52:04 +01:00 committed by sin
parent 96af28da60
commit c5f17bd3dc
5 changed files with 14 additions and 12 deletions

3
chvt.c
View File

@ -28,7 +28,8 @@ usage(void)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int n, i, fd; unsigned int n, i;
int fd;
char c; char c;
if(argc!=2 || strspn(argv[1], "1234567890") != strlen(argv[1])) if(argc!=2 || strspn(argv[1], "1234567890") != strlen(argv[1]))

View File

@ -84,6 +84,7 @@ dmesg_show(int fd, const void *buf, size_t n)
int last = '\n'; int last = '\n';
char newbuf[n], *q = newbuf; char newbuf[n], *q = newbuf;
const char *p = buf; const char *p = buf;
ssize_t r;
size_t i; size_t i;
memset(newbuf, 0, n); memset(newbuf, 0, n);
@ -97,7 +98,8 @@ dmesg_show(int fd, const void *buf, size_t n)
} }
last = p[i++]; last = p[i++];
} }
if (write(fd, newbuf, n) != n) r = write(fd, newbuf, n);
if(r < 0 || (size_t)r != n)
return -1; return -1;
if (last != '\n') if (last != '\n')
if (write(fd, "\n", 1) != 1) if (write(fd, "\n", 1) != 1)

View File

@ -27,7 +27,7 @@ main(int argc, char *argv[])
struct sigaction sa; struct sigaction sa;
char term[128], logname[LOGIN_NAME_MAX], c; char term[128], logname[LOGIN_NAME_MAX], c;
char hostname[HOST_NAME_MAX + 1]; char hostname[HOST_NAME_MAX + 1];
int i = 0; unsigned int i = 0;
ssize_t n; ssize_t n;
ARGBEGIN { ARGBEGIN {

View File

@ -18,7 +18,7 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
char *buf = NULL, *opts = NULL; char *buf = NULL, *opts = NULL;
unsigned long blen, plen = 0; size_t blen, plen = 0;
int i, fd; int i, fd;
ssize_t n; ssize_t n;
struct stat sb; struct stat sb;
@ -36,12 +36,12 @@ main(int argc, char *argv[])
eprintf("open %s:", argv[0]); eprintf("open %s:", argv[0]);
if (fstat(fd, &sb) < 0) if (fstat(fd, &sb) < 0)
eprintf("stat %s:", argv[0]); eprintf("stat %s:", argv[0]);
buf = malloc(sb.st_size);
if (!buf)
eprintf("malloc:");
blen = sb.st_size; 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:"); eprintf("read:");
argc--; argc--;
@ -51,9 +51,8 @@ main(int argc, char *argv[])
plen += strlen(argv[i]); plen += strlen(argv[i]);
if (plen > 0) { if (plen > 0) {
plen += argc; plen += argc;
opts = calloc(1, plen); if(!(opts = calloc(1, plen)))
if (!opts) eprintf("calloc:");
eprintf("malloc:");
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
strcat(opts, argv[i]); strcat(opts, argv[i]);
if (i + 1 < argc) if (i + 1 < argc)

View File

@ -51,7 +51,7 @@ parsestat(pid_t pid, struct procstat *ps)
&ps->sid, &ps->tty_nr, &ps->tpgid, &ps->flags, &ps->sid, &ps->tty_nr, &ps->tpgid, &ps->flags,
&ps->minflt, &ps->cminflt, &ps->majflt, &ps->cmajflt, &ps->minflt, &ps->cminflt, &ps->majflt, &ps->cmajflt,
&ps->utime, &ps->stime); &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->cutime, &ps->cstime, &ps->priority, &ps->nice,
&ps->num_threads, &ps->itrealvalue, &ps->starttime, &ps->num_threads, &ps->itrealvalue, &ps->starttime,
&ps->vsize, &ps->rss, &ps->rsslim); &ps->vsize, &ps->rss, &ps->rsslim);