From e698dad8780ed5ac00ab9cecdd0f6edf5443d81d Mon Sep 17 00:00:00 2001 From: Unia Date: Mon, 15 Apr 2013 21:18:25 +0200 Subject: [PATCH] fixed segfault when carrier is empty --- PKGBUILD | 2 +- dwmst.c | 7 +++---- dwmst.h | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 17e0bec..23689c4 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -2,7 +2,7 @@ pkgname=dwmst-git _gitname=dwmst -pkgver=2013.04.10 +pkgver=2013.04.14 pkgrel=1 pkgdesc="Hardcoded statusbar for DWM" arch=('any') diff --git a/dwmst.c b/dwmst.c index e3d9527..a2f89e8 100644 --- a/dwmst.c +++ b/dwmst.c @@ -87,11 +87,10 @@ int main() { /* NET */ if (++netloops > 60) { netloops = 0; - infile = fopen(NET_FILE, "r"); - fscanf(infile, "%d\n", &net); fclose(infile); - if(net == 1) + if(fopen(NET_FILE, "r")) { + fclose(infile); sprintf(netstring, LAN_STR); - else { + } else { skfd = iw_sockets_open(); if (iw_get_basic_config(skfd, WLAN, &(winfo->b)) > -1) { if (iw_get_stats(skfd, WLAN, &(winfo->stats), &winfo->range, winfo->has_range) >= 0) diff --git a/dwmst.h b/dwmst.h index c207f09..9da23bb 100644 --- a/dwmst.h +++ b/dwmst.h @@ -43,7 +43,7 @@ #define MUSIC_P_STR "P: \x02%s " /* Music, paused */ #define MUSIC_S_STR "" /* Music, stopped */ #endif -#define SKYPE_STR "\x02Skype \x01" /*Skype is running */ +#define SKYPE_STR "\x02Skype \x01" /* Skype is running */ #define NO_SKYPE_STR "" /* Skype is not running */ #define LAN_STR "Verbonden \x01" /* LAN */ #define WLAN_STR "%s \x02%d%% \x01" /* WLAN */ @@ -62,7 +62,7 @@ Display *dpy; Window root; FILE *infile; -int perc, hours, minutes, seconds = -1, net, skfd, mute = 0, realvol = 0, netloops = 60, musicloops = 10; +int perc, hours, minutes, seconds = -1, skfd, mute = 0, realvol = 0, netloops = 60, musicloops = 10; long now = -1, full = -1, voltage = -1, rate = -1, vol = 0, max = 0, min = 0; char state[8], statnext[100], status[200], netstring[30], musicstring[100]; struct wireless_info *winfo;