Skip to content

Commit

Permalink
Suppress warnings about missing led configuration toggles
Browse files Browse the repository at this point in the history
Since custom led patterns can be added via ini-files and enable/disable
configuration deals with default patterns only, mce should not complain
about missing led configuration keys by default.

[mce] Suppress warnings about missing led configuration toggles. Fixes JB#20539
  • Loading branch information
spiiroin committed Jun 17, 2014
1 parent bbd6c2b commit 474e1fd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mce-gconf.c
Expand Up @@ -30,6 +30,31 @@ static gboolean gconf_disabled = FALSE;
/** List of GConf notifiers */
static GSList *gconf_notifiers = NULL;

/** Check if gconf-key exists
*
* @param key Name of value
*
* @return TRUE if value exits, FALSE otherwise
*/
gboolean mce_gconf_has_key(const gchar *const key)
{
gboolean res = FALSE;
GConfValue *val = 0;
GError *err = 0;

if( gconf_disabled )
goto EXIT;

val = gconf_client_get(gconf_client, key, &err);
res = (val != 0);

EXIT:
g_clear_error(&err);
gconf_value_free(val);

return res;
}

/**
* Set an integer GConf key to the specified value
*
Expand Down
1 change: 1 addition & 0 deletions mce-gconf.h
Expand Up @@ -23,6 +23,7 @@

#include "builtin-gconf.h"

gboolean mce_gconf_has_key(const gchar *const key);
gboolean mce_gconf_set_int(const gchar *const key, const gint value);
gboolean mce_gconf_get_bool(const gchar *const key, gboolean *value);
gboolean mce_gconf_get_int(const gchar *const key, gint *value);
Expand Down
9 changes: 9 additions & 0 deletions modules/led.c
Expand Up @@ -1823,11 +1823,20 @@ static gboolean pattern_get_enabled(const gchar *const patternname,
gchar *path = gconf_concat_dir_and_key(MCE_GCONF_LED_PATH,
patternname);

/* Since custom led patterns do not have persistent toggles
* in configuration, avoid complaining about missing keys
* on default verbosity level. */
if( !mce_gconf_has_key(path) ) {
mce_log(LL_INFO, "missing led config entry: %s", path);
goto EXIT;
}

/* Since we've set a default, error handling is unnecessary */
mce_gconf_notifier_add(MCE_GCONF_LED_PATH, path,
led_gconf_cb, gconf_cb_id);
mce_gconf_get_bool(path, &retval);

EXIT:
g_free(path);

return retval;
Expand Down

0 comments on commit 474e1fd

Please sign in to comment.