1
0
Fork 0

do not rely on obsolete feature

function prototype with unspecified argument is obsolete since c99.

additionally some of these function which don't take any argument were
being called with a `const char *` arg, which is UB.

fix both these issues by declararing ALL the components to accept a
`const char *`, and name the arg "unused" if it's meant to be ignored.
This commit is contained in:
NRK 2022-10-27 02:16:05 +06:00 committed by drkhsh
parent 28ef0b242c
commit 0c2b3e5b5c
13 changed files with 61 additions and 61 deletions

View file

@ -8,7 +8,7 @@
#if defined(__linux__) #if defined(__linux__)
const char * const char *
cpu_freq(void) cpu_freq(const char *unused)
{ {
uintmax_t freq; uintmax_t freq;
@ -22,7 +22,7 @@
} }
const char * const char *
cpu_perc(void) cpu_perc(const char *unused)
{ {
static long double a[7]; static long double a[7];
long double b[7], sum; long double b[7], sum;
@ -55,7 +55,7 @@
#include <sys/sysctl.h> #include <sys/sysctl.h>
const char * const char *
cpu_freq(void) cpu_freq(const char *unused)
{ {
int freq, mib[2]; int freq, mib[2];
size_t size; size_t size;
@ -75,7 +75,7 @@
} }
const char * const char *
cpu_perc(void) cpu_perc(const char *unused)
{ {
int mib[2]; int mib[2];
static uintmax_t a[CPUSTATES]; static uintmax_t a[CPUSTATES];
@ -115,7 +115,7 @@
#include <devstat.h> #include <devstat.h>
const char * const char *
cpu_freq(void) cpu_freq(const char *unused)
{ {
int freq; int freq;
size_t size; size_t size;
@ -132,7 +132,7 @@
} }
const char * const char *
cpu_perc(void) cpu_perc(const char *unused)
{ {
size_t size; size_t size;
static long a[CPUSTATES]; static long a[CPUSTATES];

View file

@ -7,7 +7,7 @@
#include "../util.h" #include "../util.h"
const char * const char *
entropy(void) entropy(const char *unused)
{ {
uintmax_t num; uintmax_t num;
@ -20,7 +20,7 @@
} }
#elif defined(__OpenBSD__) | defined(__FreeBSD__) #elif defined(__OpenBSD__) | defined(__FreeBSD__)
const char * const char *
entropy(void) entropy(const char *unused)
{ {
/* Unicode Character 'INFINITY' (U+221E) */ /* Unicode Character 'INFINITY' (U+221E) */
return "\xe2\x88\x9e"; return "\xe2\x88\x9e";

View file

@ -6,7 +6,7 @@
#include "../slstatus.h" #include "../slstatus.h"
const char * const char *
hostname(void) hostname(const char *unused)
{ {
if (gethostname(buf, sizeof(buf)) < 0) { if (gethostname(buf, sizeof(buf)) < 0) {
warn("gethostbyname:"); warn("gethostbyname:");

View file

@ -6,7 +6,7 @@
#include "../slstatus.h" #include "../slstatus.h"
const char * const char *
kernel_release(void) kernel_release(const char *unused)
{ {
struct utsname udata; struct utsname udata;

View file

@ -47,7 +47,7 @@ get_layout(char *syms, int grp_num)
} }
const char * const char *
keymap(void) keymap(const char *unused)
{ {
Display *dpy; Display *dpy;
XkbDescRec *desc; XkbDescRec *desc;

View file

@ -6,7 +6,7 @@
#include "../slstatus.h" #include "../slstatus.h"
const char * const char *
load_avg(void) load_avg(const char *unused)
{ {
double avgs[3]; double avgs[3];

View file

@ -8,7 +8,7 @@
#include <stdint.h> #include <stdint.h>
const char * const char *
ram_free(void) ram_free(const char *unused)
{ {
uintmax_t free; uintmax_t free;
@ -24,7 +24,7 @@
} }
const char * const char *
ram_perc(void) ram_perc(const char *unused)
{ {
uintmax_t total, free, buffers, cached; uintmax_t total, free, buffers, cached;
@ -47,7 +47,7 @@
} }
const char * const char *
ram_total(void) ram_total(const char *unused)
{ {
uintmax_t total; uintmax_t total;
@ -60,7 +60,7 @@
} }
const char * const char *
ram_used(void) ram_used(const char *unused)
{ {
uintmax_t total, free, buffers, cached; uintmax_t total, free, buffers, cached;
@ -102,7 +102,7 @@
} }
const char * const char *
ram_free(void) ram_free(const char *unused)
{ {
struct uvmexp uvmexp; struct uvmexp uvmexp;
int free_pages; int free_pages;
@ -117,7 +117,7 @@
} }
const char * const char *
ram_perc(void) ram_perc(const char *unused)
{ {
struct uvmexp uvmexp; struct uvmexp uvmexp;
int percent; int percent;
@ -131,7 +131,7 @@
} }
const char * const char *
ram_total(void) ram_total(const char *unused)
{ {
struct uvmexp uvmexp; struct uvmexp uvmexp;
@ -145,7 +145,7 @@
} }
const char * const char *
ram_used(void) ram_used(const char *unused)
{ {
struct uvmexp uvmexp; struct uvmexp uvmexp;
@ -164,7 +164,7 @@
#include <vm/vm_param.h> #include <vm/vm_param.h>
const char * const char *
ram_free(void) { ram_free(const char *unused) {
struct vmtotal vm_stats; struct vmtotal vm_stats;
int mib[] = {CTL_VM, VM_TOTAL}; int mib[] = {CTL_VM, VM_TOTAL};
size_t len; size_t len;
@ -178,7 +178,7 @@
} }
const char * const char *
ram_total(void) { ram_total(const char *unused) {
unsigned int npages; unsigned int npages;
size_t len; size_t len;
@ -191,7 +191,7 @@
} }
const char * const char *
ram_perc(void) { ram_perc(const char *unused) {
unsigned int npages; unsigned int npages;
unsigned int active; unsigned int active;
size_t len; size_t len;
@ -209,7 +209,7 @@
} }
const char * const char *
ram_used(void) { ram_used(const char *unused) {
unsigned int active; unsigned int active;
size_t len; size_t len;

View file

@ -59,7 +59,7 @@
} }
const char * const char *
swap_free(void) swap_free(const char *unused)
{ {
long free; long free;
@ -71,7 +71,7 @@
} }
const char * const char *
swap_perc(void) swap_perc(const char *unused)
{ {
long total, free, cached; long total, free, cached;
@ -83,7 +83,7 @@
} }
const char * const char *
swap_total(void) swap_total(const char *unused)
{ {
long total; long total;
@ -95,7 +95,7 @@
} }
const char * const char *
swap_used(void) swap_used(const char *unused)
{ {
long total, free, cached; long total, free, cached;
@ -148,7 +148,7 @@
} }
const char * const char *
swap_free(void) swap_free(const char *unused)
{ {
int total, used; int total, used;
@ -160,7 +160,7 @@
} }
const char * const char *
swap_perc(void) swap_perc(const char *unused)
{ {
int total, used; int total, used;
@ -176,7 +176,7 @@
} }
const char * const char *
swap_total(void) swap_total(const char *unused)
{ {
int total, used; int total, used;
@ -188,7 +188,7 @@
} }
const char * const char *
swap_used(void) swap_used(const char *unused)
{ {
int total, used; int total, used;
@ -226,7 +226,7 @@
} }
const char * const char *
swap_free(void) swap_free(const char *unused)
{ {
struct kvm_swap swap_info[1]; struct kvm_swap swap_info[1];
long used, total; long used, total;
@ -241,7 +241,7 @@
} }
const char * const char *
swap_perc(void) swap_perc(const char *unused)
{ {
struct kvm_swap swap_info[1]; struct kvm_swap swap_info[1];
long used, total; long used, total;
@ -256,7 +256,7 @@
} }
const char * const char *
swap_total(void) swap_total(const char *unused)
{ {
struct kvm_swap swap_info[1]; struct kvm_swap swap_info[1];
long total; long total;
@ -270,7 +270,7 @@
} }
const char * const char *
swap_used(void) swap_used(const char *unused)
{ {
struct kvm_swap swap_info[1]; struct kvm_swap swap_info[1];
long used; long used;

View file

@ -15,7 +15,7 @@
#endif #endif
const char * const char *
uptime(void) uptime(const char *unused)
{ {
char warn_buf[256]; char warn_buf[256];
uintmax_t h, m; uintmax_t h, m;

View file

@ -8,13 +8,13 @@
#include "../slstatus.h" #include "../slstatus.h"
const char * const char *
gid(void) gid(const char *unused)
{ {
return bprintf("%d", getgid()); return bprintf("%d", getgid());
} }
const char * const char *
username(void) username(const char *unused)
{ {
struct passwd *pw; struct passwd *pw;
@ -27,7 +27,7 @@ username(void)
} }
const char * const char *
uid(void) uid(const char *unused)
{ {
return bprintf("%d", geteuid()); return bprintf("%d", geteuid());
} }

View file

@ -12,7 +12,7 @@ X11LIB = /usr/X11R6/lib
# flags # flags
CPPFLAGS = -I$(X11INC) -D_DEFAULT_SOURCE CPPFLAGS = -I$(X11INC) -D_DEFAULT_SOURCE
CFLAGS = -std=c99 -pedantic -Wall -Wextra -Os CFLAGS = -std=c99 -pedantic -Wall -Wextra -Wno-unused-parameter -Os
LDFLAGS = -L$(X11LIB) -s LDFLAGS = -L$(X11LIB) -s
# OpenBSD: add -lsndio # OpenBSD: add -lsndio
# FreeBSD: add -lkvm -lsndio # FreeBSD: add -lkvm -lsndio

View file

@ -12,7 +12,7 @@
#include "util.h" #include "util.h"
struct arg { struct arg {
const char *(*func)(); const char *(*func)(const char *);
const char *fmt; const char *fmt;
const char *args; const char *args;
}; };

View file

@ -6,8 +6,8 @@ const char *battery_state(const char *);
const char *battery_remaining(const char *); const char *battery_remaining(const char *);
/* cpu */ /* cpu */
const char *cpu_freq(void); const char *cpu_freq(const char *unused);
const char *cpu_perc(void); const char *cpu_perc(const char *unused);
/* datetime */ /* datetime */
const char *datetime(const char *fmt); const char *datetime(const char *fmt);
@ -19,26 +19,26 @@ const char *disk_total(const char *path);
const char *disk_used(const char *path); const char *disk_used(const char *path);
/* entropy */ /* entropy */
const char *entropy(void); const char *entropy(const char *unused);
/* hostname */ /* hostname */
const char *hostname(void); const char *hostname(const char *unused);
/* ip */ /* ip */
const char *ipv4(const char *interface); const char *ipv4(const char *interface);
const char *ipv6(const char *interface); const char *ipv6(const char *interface);
/* kernel_release */ /* kernel_release */
const char *kernel_release(void); const char *kernel_release(const char *unused);
/* keyboard_indicators */ /* keyboard_indicators */
const char *keyboard_indicators(const char *fmt); const char *keyboard_indicators(const char *fmt);
/* keymap */ /* keymap */
const char *keymap(void); const char *keymap(const char *unused);
/* load_avg */ /* load_avg */
const char *load_avg(void); const char *load_avg(const char *unused);
/* netspeeds */ /* netspeeds */
const char *netspeed_rx(const char *interface); const char *netspeed_rx(const char *interface);
@ -48,10 +48,10 @@ const char *netspeed_tx(const char *interface);
const char *num_files(const char *path); const char *num_files(const char *path);
/* ram */ /* ram */
const char *ram_free(void); const char *ram_free(const char *unused);
const char *ram_perc(void); const char *ram_perc(const char *unused);
const char *ram_total(void); const char *ram_total(const char *unused);
const char *ram_used(void); const char *ram_used(const char *unused);
/* run_command */ /* run_command */
const char *run_command(const char *cmd); const char *run_command(const char *cmd);
@ -60,21 +60,21 @@ const char *run_command(const char *cmd);
const char *separator(const char *separator); const char *separator(const char *separator);
/* swap */ /* swap */
const char *swap_free(void); const char *swap_free(const char *unused);
const char *swap_perc(void); const char *swap_perc(const char *unused);
const char *swap_total(void); const char *swap_total(const char *unused);
const char *swap_used(void); const char *swap_used(const char *unused);
/* temperature */ /* temperature */
const char *temp(const char *); const char *temp(const char *);
/* uptime */ /* uptime */
const char *uptime(void); const char *uptime(const char *unused);
/* user */ /* user */
const char *gid(void); const char *gid(const char *unused);
const char *username(void); const char *username(const char *unused);
const char *uid(void); const char *uid(const char *unused);
/* volume */ /* volume */
const char *vol_perc(const char *card); const char *vol_perc(const char *card);