Skip to content

Commit 51ff7ce

Browse files
committed
Consistent paramter naming for components
1 parent efa26f4 commit 51ff7ce

File tree

5 files changed

+43
-43
lines changed

5 files changed

+43
-43
lines changed

components/disk.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55
#include "../util.h"
66

77
const char *
8-
disk_free(const char *mnt)
8+
disk_free(const char *path)
99
{
1010
struct statvfs fs;
1111

12-
if (statvfs(mnt, &fs) < 0) {
13-
warn("statvfs '%s':", mnt);
12+
if (statvfs(path, &fs) < 0) {
13+
warn("statvfs '%s':", path);
1414
return NULL;
1515
}
1616

1717
return fmt_human(fs.f_frsize * fs.f_bavail, 1024);
1818
}
1919

2020
const char *
21-
disk_perc(const char *mnt)
21+
disk_perc(const char *path)
2222
{
2323
struct statvfs fs;
2424

25-
if (statvfs(mnt, &fs) < 0) {
26-
warn("statvfs '%s':", mnt);
25+
if (statvfs(path, &fs) < 0) {
26+
warn("statvfs '%s':", path);
2727
return NULL;
2828
}
2929

@@ -32,25 +32,25 @@ disk_perc(const char *mnt)
3232
}
3333

3434
const char *
35-
disk_total(const char *mnt)
35+
disk_total(const char *path)
3636
{
3737
struct statvfs fs;
3838

39-
if (statvfs(mnt, &fs) < 0) {
40-
warn("statvfs '%s':", mnt);
39+
if (statvfs(path, &fs) < 0) {
40+
warn("statvfs '%s':", path);
4141
return NULL;
4242
}
4343

4444
return fmt_human(fs.f_frsize * fs.f_blocks, 1024);
4545
}
4646

4747
const char *
48-
disk_used(const char *mnt)
48+
disk_used(const char *path)
4949
{
5050
struct statvfs fs;
5151

52-
if (statvfs(mnt, &fs) < 0) {
53-
warn("statvfs '%s':", mnt);
52+
if (statvfs(path, &fs) < 0) {
53+
warn("statvfs '%s':", path);
5454
return NULL;
5555
}
5656

components/ip.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "../util.h"
1212

1313
static const char *
14-
ip(const char *iface, unsigned short sa_family)
14+
ip(const char *interface, unsigned short sa_family)
1515
{
1616
struct ifaddrs *ifaddr, *ifa;
1717
int s;
@@ -28,7 +28,7 @@ ip(const char *iface, unsigned short sa_family)
2828
}
2929
s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6),
3030
host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
31-
if (!strcmp(ifa->ifa_name, iface) &&
31+
if (!strcmp(ifa->ifa_name, interface) &&
3232
(ifa->ifa_addr->sa_family == sa_family)) {
3333
freeifaddrs(ifaddr);
3434
if (s != 0) {
@@ -45,13 +45,13 @@ ip(const char *iface, unsigned short sa_family)
4545
}
4646

4747
const char *
48-
ipv4(const char *iface)
48+
ipv4(const char *interface)
4949
{
50-
return ip(iface, AF_INET);
50+
return ip(interface, AF_INET);
5151
}
5252

5353
const char *
54-
ipv6(const char *iface)
54+
ipv6(const char *interface)
5555
{
56-
return ip(iface, AF_INET6);
56+
return ip(interface, AF_INET6);
5757
}

components/num_files.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
#include "../util.h"
77

88
const char *
9-
num_files(const char *dir)
9+
num_files(const char *path)
1010
{
1111
struct dirent *dp;
1212
DIR *fd;
1313
int num;
1414

15-
if (!(fd = opendir(dir))) {
16-
warn("opendir '%s':", dir);
15+
if (!(fd = opendir(path))) {
16+
warn("opendir '%s':", path);
1717
return NULL;
1818
}
1919

components/wifi.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <linux/wireless.h>
1414

1515
const char *
16-
wifi_perc(const char *iface)
16+
wifi_perc(const char *interface)
1717
{
1818
int i, cur;
1919
int total = 70; /* the max of /proc/net/wireless */
@@ -24,7 +24,7 @@
2424

2525
if (esnprintf(path, sizeof(path),
2626
"/sys/class/net/%s/operstate",
27-
iface) < 0) {
27+
interface) < 0) {
2828
return NULL;
2929
}
3030
if (!(fp = fopen(path, "r"))) {
@@ -51,19 +51,19 @@
5151
return NULL;
5252
}
5353

54-
if (!(datastart = strstr(buf, iface))) {
54+
if (!(datastart = strstr(buf, interface))) {
5555
return NULL;
5656
}
5757

58-
datastart = (datastart+(strlen(iface)+1));
58+
datastart = (datastart+(strlen(interface)+1));
5959
sscanf(datastart + 1, " %*d %d %*d %*d\t\t %*d\t "
6060
"%*d\t\t%*d\t\t %*d\t %*d\t\t %*d", &cur);
6161

6262
return bprintf("%d", (int)((float)cur / total * 100));
6363
}
6464

6565
const char *
66-
wifi_essid(const char *iface)
66+
wifi_essid(const char *interface)
6767
{
6868
static char id[IW_ESSID_MAX_SIZE+1];
6969
int sockfd;
@@ -72,7 +72,7 @@
7272
memset(&wreq, 0, sizeof(struct iwreq));
7373
wreq.u.essid.length = IW_ESSID_MAX_SIZE+1;
7474
if (esnprintf(wreq.ifr_name, sizeof(wreq.ifr_name),
75-
"%s", iface) < 0) {
75+
"%s", interface) < 0) {
7676
return NULL;
7777
}
7878

@@ -105,7 +105,7 @@
105105
#include <sys/types.h>
106106

107107
static int
108-
load_ieee80211_nodereq(const char *iface, struct ieee80211_nodereq *nr)
108+
load_ieee80211_nodereq(const char *interface, struct ieee80211_nodereq *nr)
109109
{
110110
struct ieee80211_bssid bssid;
111111
int sockfd;
@@ -117,7 +117,7 @@
117117
warn("socket 'AF_INET':");
118118
return 0;
119119
}
120-
strlcpy(bssid.i_name, iface, sizeof(bssid.i_name));
120+
strlcpy(bssid.i_name, interface, sizeof(bssid.i_name));
121121
if ((ioctl(sockfd, SIOCG80211BSSID, &bssid)) < 0) {
122122
warn("ioctl 'SIOCG80211BSSID':");
123123
close(sockfd);
@@ -129,7 +129,7 @@
129129
close(sockfd);
130130
return 0;
131131
}
132-
strlcpy(nr->nr_ifname, iface, sizeof(nr->nr_ifname));
132+
strlcpy(nr->nr_ifname, interface, sizeof(nr->nr_ifname));
133133
memcpy(&nr->nr_macaddr, bssid.i_bssid, sizeof(nr->nr_macaddr));
134134
if ((ioctl(sockfd, SIOCG80211NODE, nr)) < 0 && nr->nr_rssi) {
135135
warn("ioctl 'SIOCG80211NODE':");
@@ -141,12 +141,12 @@
141141
}
142142

143143
const char *
144-
wifi_perc(const char *iface)
144+
wifi_perc(const char *interface)
145145
{
146146
struct ieee80211_nodereq nr;
147147
int q;
148148

149-
if (load_ieee80211_nodereq(iface, &nr)) {
149+
if (load_ieee80211_nodereq(interface, &nr)) {
150150
if (nr.nr_max_rssi) {
151151
q = IEEE80211_NODEREQ_RSSI(&nr);
152152
} else {
@@ -160,11 +160,11 @@
160160
}
161161

162162
const char *
163-
wifi_essid(const char *iface)
163+
wifi_essid(const char *interface)
164164
{
165165
struct ieee80211_nodereq nr;
166166

167-
if (load_ieee80211_nodereq(iface, &nr)) {
167+
if (load_ieee80211_nodereq(interface, &nr)) {
168168
return bprintf("%s", nr.nr_nwid);
169169
}
170170

slstatus.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ const char *cpu_perc(void);
1313
const char *datetime(const char *fmt);
1414

1515
/* disk */
16-
const char *disk_free(const char *mnt);
17-
const char *disk_perc(const char *mnt);
18-
const char *disk_total(const char *mnt);
19-
const char *disk_used(const char *mnt);
16+
const char *disk_free(const char *path);
17+
const char *disk_perc(const char *path);
18+
const char *disk_total(const char *path);
19+
const char *disk_used(const char *path);
2020

2121
/* entropy */
2222
const char *entropy(void);
@@ -25,8 +25,8 @@ const char *entropy(void);
2525
const char *hostname(void);
2626

2727
/* ip */
28-
const char *ipv4(const char *iface);
29-
const char *ipv6(const char *iface);
28+
const char *ipv4(const char *interface);
29+
const char *ipv6(const char *interface);
3030

3131
/* kernel_release */
3232
const char *kernel_release(void);
@@ -45,7 +45,7 @@ const char *netspeed_rx(const char *interface);
4545
const char *netspeed_tx(const char *interface);
4646

4747
/* num_files */
48-
const char *num_files(const char *dir);
48+
const char *num_files(const char *path);
4949

5050
/* ram */
5151
const char *ram_free(void);
@@ -77,5 +77,5 @@ const char *uid(void);
7777
const char *vol_perc(const char *card);
7878

7979
/* wifi */
80-
const char *wifi_perc(const char *iface);
81-
const char *wifi_essid(const char *iface);
80+
const char *wifi_perc(const char *interface);
81+
const char *wifi_essid(const char *interface);

0 commit comments

Comments
 (0)