Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Making sysinfod D-Bus queries is disabled at compile time
If sysinfod is not available by design, the D-Bus queries just result in
less than useful D-Bus error logging on mce startup.

Context specific error logging is still done at the places where
the dbus queries are attempted.
  • Loading branch information
spiiroin committed Nov 16, 2012
1 parent 80dad85 commit de46ea2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
7 changes: 7 additions & 0 deletions Makefile
Expand Up @@ -14,6 +14,9 @@ DOXYGEN := doxygen
# Whether to enable wakelock compatibility code
ENABLE_WAKELOCKS ?= n

# Whether to enable sysinfod queries
ENABLE_SYSINFOD_QUERIES ?= n

VARDIR := $(DESTDIR)/var/lib/mce
RUNDIR := $(DESTDIR)/var/run/mce
CONFDIR := /etc/mce
Expand Down Expand Up @@ -92,6 +95,10 @@ ifeq ($(strip $(ENABLE_WAKELOCKS)),y)
COMMON_CFLAGS += -DENABLE_WAKELOCKS
endif

ifeq ($(strip $(ENABLE_SYSINFOD_QUERIES)),y)
COMMON_CFLAGS += -DENABLE_SYSINFOD_QUERIES
endif

MCE_CFLAGS := $(COMMON_CFLAGS)
MCE_CFLAGS += -DMCE_CONF_FILE=$(CONFDIR)/$(CONFFILE)
MCE_CFLAGS += $$(pkg-config gobject-2.0 glib-2.0 gio-2.0 gmodule-2.0 dbus-1 dbus-glib-1 gconf-2.0 --cflags)
Expand Down
27 changes: 16 additions & 11 deletions mce-hal.c
Expand Up @@ -81,6 +81,7 @@ static product_id_t product_id = PRODUCT_UNSET;
*/
gboolean get_sysinfo_value(const gchar *const key, guint8 **array, gulong *len)
{
#ifdef ENABLE_SYSINFOD_QUERIES
DBusMessage *reply;
guint8 *tmp = NULL;
gboolean status = FALSE;
Expand Down Expand Up @@ -110,6 +111,11 @@ gboolean get_sysinfo_value(const gchar *const key, guint8 **array, gulong *len)
}

return status;
#else
/* Provide a dummy function that always fails silently */
return (void)key, *array = 0, *len = 0, FALSE;
#endif /* ENABLE_SYSINFOD_QUERIES */

}

/**
Expand All @@ -120,19 +126,17 @@ gboolean get_sysinfo_value(const gchar *const key, guint8 **array, gulong *len)
product_id_t get_product_id(void)
{
guint8 *tmp = NULL;
gulong len;
gulong len = 0;

if (product_id != PRODUCT_UNSET)
goto EXIT;

if (get_sysinfo_value(PRODUCT_SYSINFO_KEY, &tmp, &len) == FALSE) {
mce_log(LL_ERR,
"Failed to get the product ID");
product_id = PRODUCT_UNKNOWN;
goto EXIT;
}
product_id = PRODUCT_UNKNOWN;

if (strmemcmp(tmp, PRODUCT_SU18_STR, len) == TRUE) {
if( !get_sysinfo_value(PRODUCT_SYSINFO_KEY, &tmp, &len) ) {
// nothing
}
else if (strmemcmp(tmp, PRODUCT_SU18_STR, len) == TRUE) {
product_id = PRODUCT_SU18;
} else if (strmemcmp(tmp, PRODUCT_RX34_STR, len) == TRUE) {
product_id = PRODUCT_RX34;
Expand All @@ -152,12 +156,13 @@ product_id_t get_product_id(void)
product_id = PRODUCT_RM696;
} else if (strmemcmp(tmp, PRODUCT_RM716_STR, len) == TRUE) {
product_id = PRODUCT_RM716;
} else {
product_id = PRODUCT_UNKNOWN;
}

free(tmp);

if ( product_id == PRODUCT_UNKNOWN ) {
mce_log(LL_ERR, "Failed to get the product ID");
}

EXIT:
return product_id;
}

0 comments on commit de46ea2

Please sign in to comment.