From 05a85bbebdef9f8e7c1b0c09d5a2145c2f2d10af Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 2 Dec 2008 23:30:43 +0100 Subject: [PATCH] src/plugin.[ch]: Don't use unnamed unions. They're non-standard and cause a lot of trouble. --- src/exec.c | 10 +++++----- src/plugin.c | 26 +++++++++++++------------- src/plugin.h | 12 ++++++------ 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/exec.c b/src/exec.c index 711ec996..a78f902f 100644 --- a/src/exec.c +++ b/src/exec.c @@ -690,16 +690,16 @@ static void *exec_notification_one (void *arg) /* {{{ */ for (meta = n->meta; meta != NULL; meta = meta->next) { if (meta->type == NM_TYPE_STRING) - fprintf (fh, "%s: %s\n", meta->name, meta->value_string); + fprintf (fh, "%s: %s\n", meta->name, meta->nm_value.nm_string); else if (meta->type == NM_TYPE_SIGNED_INT) - fprintf (fh, "%s: %"PRIi64"\n", meta->name, meta->value_signed_int); + fprintf (fh, "%s: %"PRIi64"\n", meta->name, meta->nm_value.nm_signed_int); else if (meta->type == NM_TYPE_UNSIGNED_INT) - fprintf (fh, "%s: %"PRIu64"\n", meta->name, meta->value_unsigned_int); + fprintf (fh, "%s: %"PRIu64"\n", meta->name, meta->nm_value.nm_unsigned_int); else if (meta->type == NM_TYPE_DOUBLE) - fprintf (fh, "%s: %e\n", meta->name, meta->value_double); + fprintf (fh, "%s: %e\n", meta->name, meta->nm_value.nm_double); else if (meta->type == NM_TYPE_BOOLEAN) fprintf (fh, "%s: %s\n", meta->name, - meta->value_boolean ? "true" : "false"); + meta->nm_value.nm_boolean ? "true" : "false"); } fprintf (fh, "\n%s\n", n->message); diff --git a/src/plugin.c b/src/plugin.c index 1ec25441..a8873277 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -901,8 +901,8 @@ static int plugin_notification_meta_add (notification_t *n, { case NM_TYPE_STRING: { - meta->value_string = strdup ((const char *) value); - if (meta->value_string == NULL) + meta->nm_value.nm_string = strdup ((const char *) value); + if (meta->nm_value.nm_string == NULL) { ERROR ("plugin_notification_meta_add: strdup failed."); sfree (meta); @@ -912,22 +912,22 @@ static int plugin_notification_meta_add (notification_t *n, } case NM_TYPE_SIGNED_INT: { - meta->value_signed_int = *((int64_t *) value); + meta->nm_value.nm_signed_int = *((int64_t *) value); break; } case NM_TYPE_UNSIGNED_INT: { - meta->value_unsigned_int = *((uint64_t *) value); + meta->nm_value.nm_unsigned_int = *((uint64_t *) value); break; } case NM_TYPE_DOUBLE: { - meta->value_double = *((double *) value); + meta->nm_value.nm_double = *((double *) value); break; } case NM_TYPE_BOOLEAN: { - meta->value_boolean = *((bool *) value); + meta->nm_value.nm_boolean = *((bool *) value); break; } default: @@ -1000,19 +1000,19 @@ int plugin_notification_meta_copy (notification_t *dst, { if (meta->type == NM_TYPE_STRING) plugin_notification_meta_add_string (dst, meta->name, - meta->value_string); + meta->nm_value.nm_string); else if (meta->type == NM_TYPE_SIGNED_INT) plugin_notification_meta_add_signed_int (dst, meta->name, - meta->value_signed_int); + meta->nm_value.nm_signed_int); else if (meta->type == NM_TYPE_UNSIGNED_INT) plugin_notification_meta_add_unsigned_int (dst, meta->name, - meta->value_unsigned_int); + meta->nm_value.nm_unsigned_int); else if (meta->type == NM_TYPE_DOUBLE) plugin_notification_meta_add_double (dst, meta->name, - meta->value_double); + meta->nm_value.nm_double); else if (meta->type == NM_TYPE_BOOLEAN) plugin_notification_meta_add_boolean (dst, meta->name, - meta->value_boolean); + meta->nm_value.nm_boolean); } return (0); @@ -1037,8 +1037,8 @@ int plugin_notification_meta_free (notification_t *n) if (this->type == NM_TYPE_STRING) { - free ((char *)this->value_string); - this->value_string = NULL; + free ((char *)this->nm_value.nm_string); + this->nm_value.nm_string = NULL; } sfree (this); diff --git a/src/plugin.h b/src/plugin.h index 3ffde461..dc3bbb08 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -114,12 +114,12 @@ typedef struct notification_meta_s enum notification_meta_type_e type; union { - const char *value_string; - int64_t value_signed_int; - uint64_t value_unsigned_int; - double value_double; - bool value_boolean; - }; + const char *nm_string; + int64_t nm_signed_int; + uint64_t nm_unsigned_int; + double nm_double; + bool nm_boolean; + } nm_value; struct notification_meta_s *next; } notification_meta_t; -- 2.30.2