From 139045c12023f8af289f769b1e609428319d023e Mon Sep 17 00:00:00 2001 From: Stephen 'Okra' Houston Date: Sat, 15 Jul 2017 11:14:41 -0500 Subject: [PATCH] Sysinfo Gadget: Unify define macro checking. --- src/modules/sysinfo/batman/batman.c | 4 ++-- src/modules/sysinfo/batman/batman.h | 8 ++++---- src/modules/sysinfo/batman/batman_fallback.c | 2 +- src/modules/sysinfo/cpuclock/cpuclock.c | 18 +++++++++--------- src/modules/sysinfo/cpuclock/cpuclock.h | 2 +- src/modules/sysinfo/cpuclock/cpuclock_config.c | 4 ++-- src/modules/sysinfo/memusage/memusage.c | 4 ++-- src/modules/sysinfo/mod.c | 4 ++-- src/modules/sysinfo/sysinfo.c | 2 +- src/modules/sysinfo/sysinfo.h | 14 +++++++------- src/modules/sysinfo/thermal/thermal.h | 4 ++-- src/modules/sysinfo/thermal/thermal_sysctl.c | 10 +++++----- 12 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/modules/sysinfo/batman/batman.c b/src/modules/sysinfo/batman/batman.c index 2d69e49b6..1af63702d 100644 --- a/src/modules/sysinfo/batman/batman.c +++ b/src/modules/sysinfo/batman/batman.c @@ -605,7 +605,7 @@ sysinfo_batman_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNU E_FREE_FUNC(inst->cfg->batman.configure, evas_object_del); EINA_LIST_FREE(inst->cfg->batman.handlers, handler) ecore_event_handler_del(handler); -#ifdef HAVE_EEZE +#if defined(HAVE_EEZE) _batman_udev_stop(inst); #elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) (void) inst; @@ -731,7 +731,7 @@ _conf_item_get(int *id) ci->batman.time_left = -2; ci->batman.have_battery = -2; ci->batman.have_power = -2; -#if defined HAVE_EEZE || defined __OpenBSD__ || defined __NetBSD__ +#if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__NetBSD__) ci->batman.fuzzy = 0; #endif ci->batman.desktop_notifications = 0; diff --git a/src/modules/sysinfo/batman/batman.h b/src/modules/sysinfo/batman/batman.h index f40ce6036..1b6684551 100644 --- a/src/modules/sysinfo/batman/batman.h +++ b/src/modules/sysinfo/batman/batman.h @@ -27,12 +27,12 @@ struct _Battery { Instance *inst; const char *udi; -#if defined HAVE_EEZE || defined __OpenBSD__ || defined __DragonFly__ || defined __FreeBSD__ || defined __NetBSD__ +#if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) Ecore_Poller *poll; #endif Eina_Bool present:1; Eina_Bool charging:1; -#if defined HAVE_EEZE || defined __OpenBSD__ || defined __DragonFly__ || defined __FreeBSD__ || defined __NetBSD__ +#if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) double last_update; double percent; double current_charge; @@ -98,12 +98,12 @@ EINTERN void _batman_device_update(Instance *inst); EINTERN int _batman_fallback_start(Instance *inst); EINTERN void _batman_fallback_stop(void); /* end batman_fallback.c */ -#ifdef HAVE_EEZE +#if defined(HAVE_EEZE) /* in batman_udev.c */ EINTERN int _batman_udev_start(Instance *inst); EINTERN void _batman_udev_stop(Instance *inst); /* end batman_udev.c */ -#elif !defined __OpenBSD__ && !defined __DragonFly__ && !defined __FreeBSD__ && !defined __NetBSD__ +#elif !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__NetBSD__) /* in batman_upower.c */ EINTERN int _batman_upower_start(Instance *inst); EINTERNvoid _batman_upower_stop(void); diff --git a/src/modules/sysinfo/batman/batman_fallback.c b/src/modules/sysinfo/batman/batman_fallback.c index b6374d700..a04980a3c 100644 --- a/src/modules/sysinfo/batman/batman_fallback.c +++ b/src/modules/sysinfo/batman/batman_fallback.c @@ -1,6 +1,6 @@ #include "batman.h" -#ifdef HAVE_CFBASE_H +#if defined(HAVE_CFBASE_H) # include # include # include diff --git a/src/modules/sysinfo/cpuclock/cpuclock.c b/src/modules/sysinfo/cpuclock/cpuclock.c index a6a4940c2..35dc7892c 100644 --- a/src/modules/sysinfo/cpuclock/cpuclock.c +++ b/src/modules/sysinfo/cpuclock/cpuclock.c @@ -69,7 +69,7 @@ _cpuclock_cb_sort(const void *item1, const void *item2) return 0; } -#if defined(__FreeBSD__) || defined(__DragonFly__) || defined (__OpenBSD__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) static void _cpuclock_set_thread_frequency(void *data, Ecore_Thread *th EINA_UNUSED) { @@ -88,7 +88,7 @@ _cpuclock_set_thread_done(void *data EINA_UNUSED, Ecore_Thread *th EINA_UNUSED) void _cpuclock_set_governor(const char *governor) { -#if defined __FreeBSD__ || defined __OpenBSD__ +#if defined(__FreeBSD__) || defined(__OpenBSD__) return; #endif char buf[4096], exe[4096]; @@ -113,7 +113,7 @@ _cpuclock_set_frequency(int frequency) #endif snprintf(buf, sizeof(buf), "%i", frequency); -#if defined(__FreeBSD__) || defined(__DragonFly__) || defined (__OpenBSD__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) const char *freq; freq = eina_stringshare_add(buf); ecore_thread_run(_cpuclock_set_thread_frequency, _cpuclock_set_thread_done, NULL, freq); @@ -132,7 +132,7 @@ _cpuclock_set_frequency(int frequency) void _cpuclock_set_pstate(int min, int max, int turbo) { -#if defined __FreeBSD__ || defined __OpenBSD__ +#if defined(__FreeBSD__) || defined(__OpenBSD__) return; #endif char buf[4096], exe[4096]; @@ -444,7 +444,7 @@ _cpuclock_status_check_available(Cpu_Status *s) #endif // FIXME: this assumes all cores accept the same freqs/ might be wrong -#if defined (__OpenBSD__) +#if defined(__OpenBSD__) int p; if (s->frequencies) @@ -462,7 +462,7 @@ _cpuclock_status_check_available(Cpu_Status *s) s->frequencies = eina_list_append(s->frequencies, (void *)(long int)p); p = 25; s->frequencies = eina_list_append(s->frequencies, (void *)(long int)p); -#elif defined (__FreeBSD__) +#elif defined(__FreeBSD__) int freq; size_t len = sizeof(buf); char *pos, *q; @@ -631,7 +631,7 @@ _cpuclock_status_check_current(Cpu_Status *s) int ret = 0; int frequency = 0; -#if defined (__OpenBSD__) +#if defined(__OpenBSD__) size_t len = sizeof(frequency); int percent, mib[] = {CTL_HW, HW_CPUSPEED}; s->active = 0; @@ -656,7 +656,7 @@ _cpuclock_status_check_current(Cpu_Status *s) s->can_set_frequency = 1; s->cur_governor = NULL; -#elif defined (__FreeBSD__) +#elif defined(__FreeBSD__) size_t len = sizeof(frequency); s->active = 0; @@ -852,7 +852,7 @@ _cpuclock_cb_frequency_check_notify(void *data, if ((inst->cfg->cpuclock.status) && (status) && ( -#ifdef __OpenBSD__ +#if defined(__OpenBSD__) (status->cur_percent != inst->cfg->cpuclock.status->cur_percent ) || #endif (status->cur_frequency != inst->cfg->cpuclock.status->cur_frequency ) || diff --git a/src/modules/sysinfo/cpuclock/cpuclock.h b/src/modules/sysinfo/cpuclock/cpuclock.h index 0e5d2204e..911b49b7c 100644 --- a/src/modules/sysinfo/cpuclock/cpuclock.h +++ b/src/modules/sysinfo/cpuclock/cpuclock.h @@ -26,7 +26,7 @@ EINTERN void _cpuclock_config_updated(Instance *inst); EINTERN void _cpuclock_set_governor(const char *governor); EINTERN void _cpuclock_set_frequency(int frequency); EINTERN void _cpuclock_set_pstate(int min, int max, int turbo); -#if defined __OpenBSD__ || defined __FreeBSD__ +#if defined(__OpenBSD__) || defined(__FreeBSD__) EINTERN int _cpuclock_sysctl_frequency(int new_perf); #endif diff --git a/src/modules/sysinfo/cpuclock/cpuclock_config.c b/src/modules/sysinfo/cpuclock/cpuclock_config.c index f0d87d067..187282500 100644 --- a/src/modules/sysinfo/cpuclock/cpuclock_config.c +++ b/src/modules/sysinfo/cpuclock/cpuclock_config.c @@ -567,7 +567,7 @@ cpuclock_configure(Instance *inst) elm_radio_state_value_set(o, i); E_ALIGN(o, 0.0, 0.0); E_WEIGHT(o, EVAS_HINT_EXPAND, 0); -#ifdef __OpenBSD__ +#if defined(__OpenBSD__) snprintf(buf, sizeof(buf), "%i %%", frequency); #else if (frequency < 1000000) @@ -581,7 +581,7 @@ cpuclock_configure(Instance *inst) evas_object_smart_callback_add(o, "changed", _frequency_changed, cc); evas_object_show(o); -#ifdef __OpenBSD__ +#if defined(__OpenBSD__) if (inst->cfg->cpuclock.status->cur_percent == frequency) value = i; #else diff --git a/src/modules/sysinfo/memusage/memusage.c b/src/modules/sysinfo/memusage/memusage.c index a4a064e1f..6562c72d8 100644 --- a/src/modules/sysinfo/memusage/memusage.c +++ b/src/modules/sysinfo/memusage/memusage.c @@ -462,10 +462,10 @@ sysinfo_memusage_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U } EINA_LIST_FREE(inst->cfg->memusage.handlers, handler) ecore_event_handler_del(handler); - inst->cfg->thermal.done = EINA_TRUE; + inst->cfg->memusage.done = EINA_TRUE; if (inst->cfg->esm == E_SYSINFO_MODULE_SYSINFO) { - if (inst->cfg->memusage.done && inst->cfg->cpumonitor.done && + if (inst->cfg->thermal.done && inst->cfg->cpumonitor.done && inst->cfg->netstatus.done && inst->cfg->cpuclock.done && inst->cfg->batman.done) { sysinfo_config->items = eina_list_remove(sysinfo_config->items, inst->cfg); diff --git a/src/modules/sysinfo/mod.c b/src/modules/sysinfo/mod.c index 46c0cff5d..d3fea5ae3 100644 --- a/src/modules/sysinfo/mod.c +++ b/src/modules/sysinfo/mod.c @@ -28,7 +28,7 @@ sysinfo_init(void) E_CONFIG_VAL(D, T, batman.suspend_below, INT); E_CONFIG_VAL(D, T, batman.suspend_method, INT); E_CONFIG_VAL(D, T, batman.force_mode, INT); -#if defined HAVE_EEZE || defined __OpenBSD__ || defined __NetBSD__ +#if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__NetBSD__) E_CONFIG_VAL(D, T, batman.fuzzy, INT); #endif E_CONFIG_VAL(D, T, batman.desktop_notifications, INT); @@ -82,7 +82,7 @@ sysinfo_init(void) ci->batman.time_left = -2; ci->batman.have_battery = -2; ci->batman.have_power = -2; -#if defined HAVE_EEZE || defined __OpenBSD__ || defined __NetBSD__ +#if defined(HAVE_EEZ)E || defined(__OpenBSD__) || defined(__NetBSD__) ci->batman.fuzzy = 0; #endif ci->batman.desktop_notifications = 0; diff --git a/src/modules/sysinfo/sysinfo.c b/src/modules/sysinfo/sysinfo.c index 9a05671a0..9623652c7 100644 --- a/src/modules/sysinfo/sysinfo.c +++ b/src/modules/sysinfo/sysinfo.c @@ -101,7 +101,7 @@ _conf_item_get(int *id) ci->batman.time_left = -2; ci->batman.have_battery = -2; ci->batman.have_power = -2; -#if defined HAVE_EEZE || defined __OpenBSD__ || defined __NetBSD__ +#if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__NetBSD__) ci->batman.fuzzy = 0; #endif ci->batman.desktop_notifications = 0; diff --git a/src/modules/sysinfo/sysinfo.h b/src/modules/sysinfo/sysinfo.h index 367373f21..466ccb4dc 100644 --- a/src/modules/sysinfo/sysinfo.h +++ b/src/modules/sysinfo/sysinfo.h @@ -2,7 +2,7 @@ #define SYSINFO_H #include "e.h" -#ifdef HAVE_EEZE +#if defined(HAVE_EEZE) # include #else # include @@ -39,7 +39,7 @@ enum _Netstatus_Unit typedef enum _Sensor_Type { SENSOR_TYPE_NONE, -#if defined __FreeBSD__ || defined __OpenBSD__ || defined __DragonFly__ +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) SENSOR_TYPE_FREEBSD, SENSOR_TYPE_OPENBSD, #else @@ -77,7 +77,7 @@ struct _Tempthread const char *sensor_path; void *extn; E_Powersave_Sleeper *sleeper; -#ifdef HAVE_EEZE +#if defined(HAVE_EEZE) Eina_List *tempdevs; #endif Eina_Bool initted : 1; @@ -88,7 +88,7 @@ struct _Cpu_Status Eina_List *frequencies; Eina_List *governors; int cur_frequency; -#ifdef __OpenBSD__ +#if defined(__OpenBSD__) int cur_percent; #endif int cur_min_frequency; @@ -146,11 +146,11 @@ struct _Config_Item int desktop_notifications; Eina_List *handlers; Eina_Bool done; -#ifdef HAVE_EEZE +#if defined(HAVE_EEZE) Eeze_Udev_Watch *acwatch; Eeze_Udev_Watch *batwatch; #endif -#if defined HAVE_EEZE || defined __OpenBSD__ || defined __NetBSD__ +#if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__NetBSD__) Eina_Bool fuzzy; int fuzzcount; #endif @@ -167,7 +167,7 @@ struct _Config_Item int temp; const char *sensor_name; Unit units; -#ifdef HAVE_EEZE +#if defined(HAVE_EEZE) Ecore_Poller *poller; Tempthread *tth; #endif diff --git a/src/modules/sysinfo/thermal/thermal.h b/src/modules/sysinfo/thermal/thermal.h index a5bc26a2a..c0cb3238a 100644 --- a/src/modules/sysinfo/thermal/thermal.h +++ b/src/modules/sysinfo/thermal/thermal.h @@ -13,11 +13,11 @@ struct _Thermal_Config }; -#ifdef HAVE_EEZE +#if defined(HAVE_EEZE) EINTERN int thermal_udev_get(Tempthread *tth); #endif -#if defined __OpenBSD__ || defined __DragonFly__ || defined __FreeBSD__ +#if defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__) EINTERN int thermal_sysctl_get(Tempthread *tth); #endif diff --git a/src/modules/sysinfo/thermal/thermal_sysctl.c b/src/modules/sysinfo/thermal/thermal_sysctl.c index e17e2db3f..4eaa12483 100644 --- a/src/modules/sysinfo/thermal/thermal_sysctl.c +++ b/src/modules/sysinfo/thermal/thermal_sysctl.c @@ -49,7 +49,7 @@ init(Tempthread *tth) size_t sdlen = sizeof(snsrdev); #endif -#if defined (__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) unsigned i; size_t len; int rc; @@ -71,7 +71,7 @@ init(Tempthread *tth) eina_stringshare_del(tth->sensor_path); tth->sensor_path = NULL; -#if defined (__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) for (i = 0; sources[i]; i++) { rc = sysctlbyname(sources[i], NULL, NULL, NULL, 0); @@ -150,11 +150,11 @@ check(Tempthread *tth) { int ret = 0; int temp = 0; -#if defined (__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) size_t len; size_t ftemp = 0; #endif -#if defined (__FreeBSD__) || defined(__DragonFly__) || defined (__OpenBSD__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) Extn *extn = tth->extn; #endif @@ -164,7 +164,7 @@ check(Tempthread *tth) */ if (tth->sensor_type == SENSOR_TYPE_FREEBSD) { -#if defined (__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) len = sizeof(ftemp); if (sysctl(extn->mib, extn->miblen, &ftemp, &len, NULL, 0) == 0) {