--- config.mk | 2 +- df.c | 6 ++++-- dmesg.c | 6 ++++-- eject.c | 2 +- free.c | 12 +++++++----- getty.c | 2 +- proc.h | 5 ++++- stat.c | 2 +- su.c | 5 +++-- util/proc.c | 3 ++- 10 files changed, 28 insertions(+), 17 deletions(-) diff --git a/config.mk b/config.mk index 6587d3a..56ca30a 100644 --- a/config.mk +++ b/config.mk _AT_@ -9,5 +9,5 @@ MANPREFIX = $(PREFIX)/share/man #CC = musl-gcc LD = $(CC) CPPFLAGS = -D_XOPEN_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -CFLAGS = -std=c99 -Wall -Wextra $(CPPFLAGS) +CFLAGS = -std=c90 -Wall -Wextra -pedantic $(CPPFLAGS) LDFLAGS = -s -lcrypt # -static diff --git a/df.c b/df.c index 299c297..fe0ef35 100644 --- a/df.c +++ b/df.c _AT_@ -1,5 +1,7 @@ /* See LICENSE file for copyright and license details. */ #include <mntent.h> +#include <stdint.h> +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> _AT_@ -53,7 +55,7 @@ static void mnt_show(const char *fsname, const char *dir) { struct statvfs s; - unsigned long long total, used, avail; + uint_least64_t total, used, avail; int capacity = 0; int bs; _AT_@ -70,7 +72,7 @@ mnt_show(const char *fsname, const char *dir) capacity++; } - printf("%-12s %9llu %9llu %9llu %7d%% %s\n", + printf("%-12s %9"PRIu64" %9"PRIu64" %9"PRIu64" %7d%% %s\n", fsname, total, used, avail, capacity, dir); } diff --git a/dmesg.c b/dmesg.c index c60c503..b90d9ac 100644 --- a/dmesg.c +++ b/dmesg.c _AT_@ -80,12 +80,13 @@ static int dmesg_show(int fd, const void *buf, size_t n) { int last = '\n'; - char newbuf[n], *q = newbuf; + char *newbuf, *q; const char *p = buf; ssize_t r; size_t i; - memset(newbuf, 0, n); + newbuf = calloc(n, sizeof(char)); + q = newbuf; for (i = 0; i < n; ) { if (last == '\n' && p[i] == '<') { i += 2; _AT_@ -97,6 +98,7 @@ dmesg_show(int fd, const void *buf, size_t n) last = p[i++]; } r = write(fd, newbuf, n); + free(newbuf); if(r < 0 || (size_t)r != n) return -1; if (last != '\n') diff --git a/eject.c b/eject.c index 7d458e8..62f42fa 100644 --- a/eject.c +++ b/eject.c _AT_@ -10,7 +10,7 @@ enum { CDROM_EJECT = 0x5309, - CDROM_CLOSE_TRAY = 0x5319, + CDROM_CLOSE_TRAY = 0x5319 }; static void diff --git a/free.c b/free.c index 22681b1..b78ce7c 100644 --- a/free.c +++ b/free.c _AT_@ -1,5 +1,7 @@ /* See LICENSE file for copyright and license details. */ #include <sys/sysinfo.h> +#include <stdint.h> +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include "util.h" _AT_@ -13,8 +15,8 @@ usage(void) static unsigned int mem_unit = 1; static unsigned int unit_shift; -static unsigned long long -scale(unsigned long long v) +static uint_least64_t +scale(unsigned long v) { return (v * mem_unit) >> unit_shift; } _AT_@ -51,18 +53,18 @@ main(int argc, char *argv[]) "free", "shared", "buffers"); printf("Mem: "); - printf("%13llu%13llu%13llu%13llu%13llu\n", + printf("%13"PRIu64"%13"PRIu64"%13"PRIu64"%13"PRIu64"%13"PRIu64"\n", scale(info.totalram), scale(info.totalram - info.freeram), scale(info.freeram), scale(info.sharedram), scale(info.bufferram)); printf("-/+ buffers/cache:"); - printf("%13llu%13llu\n", + printf("%13"PRIu64"%13"PRIu64"\n", scale(info.totalram - info.freeram - info.bufferram), scale(info.freeram + info.bufferram)); printf("Swap:"); - printf("%13llu%13llu%13llu\n", + printf("%13"PRIu64"%13"PRIu64"%13"PRIu64"\n", scale(info.totalswap), scale(info.totalswap - info.freeswap), scale(info.freeswap)); diff --git a/getty.c b/getty.c index 3a580ad..6c0af00 100644 --- a/getty.c +++ b/getty.c _AT_@ -109,5 +109,5 @@ main(int argc, char *argv[]) eprintf("login name cannot start with '-'\n"); if (logname[0] == '\0') return EXIT_FAILURE; - return execvp("/bin/login", (char *[]){ "login", "-p", logname, NULL }); + return execlp("/bin/login", "login", "-p", logname, NULL); } diff --git a/proc.h b/proc.h index cb44e12..32d1a6d 100644 --- a/proc.h +++ b/proc.h _AT_@ -1,4 +1,7 @@ /* See LICENSE file for copyright and license details. */ + +#include <stdint.h> + struct procstat { int pid; char comm[PATH_MAX + 2]; /* + 2 for '(' and ')' */ _AT_@ -21,7 +24,7 @@ struct procstat { long nice; long num_threads; long itrealvalue; - unsigned long long starttime; + uint_least64_t starttime; unsigned long vsize; long rss; long rsslim; diff --git a/stat.c b/stat.c index 8bbb504..639aa2e 100644 --- a/stat.c +++ b/stat.c _AT_@ -67,7 +67,7 @@ show_stat_terse(const char *file, struct stat *st) printf("%lu %lu ", (unsigned long)st->st_size, (unsigned long)st->st_blocks); printf("%04o %u %u ", st->st_mode & 0777, st->st_uid, st->st_gid); - printf("%llx ", (unsigned long long)st->st_dev); + printf("%lx ", (unsigned long)st->st_dev); printf("%lu %lu ", (unsigned long)st->st_ino, (unsigned long)st->st_nlink); printf("%d %d ", major(st->st_rdev), minor(st->st_rdev)); printf("%ld %ld %ld ", st->st_atime, st->st_mtime, st->st_ctime); diff --git a/su.c b/su.c index 47d3fe7..441a966 100644 --- a/su.c +++ b/su.c _AT_@ -31,9 +31,9 @@ int main(int argc, char *argv[]) { char *usr = "root", *pass, *cryptpass; - char * const *newargv; struct spwd *spw; struct passwd *pw; + char *newargv[2]; uid_t uid; ARGBEGIN { _AT_@ -121,7 +121,8 @@ dosu: if (lflag) { return dologin(pw); } else { - newargv = (char *const[]){pw->pw_shell, NULL}; + newargv[0] = pw->pw_shell; + newargv[1] = NULL; if (!pflag) { setenv("HOME", pw->pw_dir, 1); setenv("SHELL", pw->pw_shell, 1); diff --git a/util/proc.c b/util/proc.c index fa968e7..f6d9226 100644 --- a/util/proc.c +++ b/util/proc.c _AT_@ -3,6 +3,7 @@ #include <fcntl.h> #include <unistd.h> #include <errno.h> +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> _AT_@ -51,7 +52,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 %llu %lu %ld %ld", + fscanf(fp, "%ld %ld %ld %ld %ld %ld %"PRIu64" %lu %ld %ld", &ps->cutime, &ps->cstime, &ps->priority, &ps->nice, &ps->num_threads, &ps->itrealvalue, &ps->starttime, &ps->vsize, &ps->rss, &ps->rsslim); -- 1.8.5.5 --Multipart=_Wed__4_Jun_2014_17_28_50_+0200_Mk_fhqb269=Xfo6R--Received on Mon Sep 17 2001 - 00:00:00 CEST
This archive was generated by hypermail 2.3.0 : Wed Jun 04 2014 - 17:36:14 CEST