removed useless union
authorJean-Philippe Orsini <jeanfi@gmail.com>
Thu, 26 Apr 2012 10:40:08 +0000 (10:40 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Thu, 26 Apr 2012 10:40:08 +0000 (10:40 +0000)
src/graph.c
src/lib/measure.c
src/lib/measure.h
src/lib/psensor.c
src/lib/psensor_json.c
src/ui_notify.c
src/ui_sensorlist.c

index 06d7c8b..a52b69e 100644 (file)
@@ -187,7 +187,7 @@ static void draw_sensor_curve(struct psensor *s,
        first = 1;
        for (i = 0; i < s->values_max_length; i++) {
                t = s->measures[i].time.tv_sec;
-               v = s->measures[i].value.d_num;
+               v = s->measures[i].value;
 
                if (v == UNKNOWN_DBL_VALUE || !t)
                        continue;
index 92aa5bd..9f6225a 100644 (file)
@@ -30,7 +30,7 @@ struct measure *measures_dbl_create(int size)
        result = malloc(size * sizeof(struct measure));
 
        for (i = 0; i < size; i++) {
-               result[i].value.d_num = UNKNOWN_DBL_VALUE;
+               result[i].value = UNKNOWN_DBL_VALUE;
                timerclear(&result[i].time);
        }
 
index f95ce51..b25fcff 100644 (file)
 #define UNKNOWN_DBL_VALUE DBL_MIN
 
 struct measure {
-       union value {
-               double d_num;
-               uint64_t ui64_num;
-       } value;
+       double value;
 
        struct timeval time;
 };
index 89ed97e..4efbdc6 100644 (file)
@@ -255,7 +255,7 @@ psensor_set_current_measure(struct psensor *s,
                &s->measures[1],
                (s->values_max_length - 1) * sizeof(struct measure));
 
-       s->measures[s->values_max_length - 1].value.d_num = v;
+       s->measures[s->values_max_length - 1].value = v;
        s->measures[s->values_max_length - 1].time = tv;
 
        if (s->min == UNKNOWN_DBL_VALUE || v < s->min)
@@ -279,7 +279,7 @@ psensor_set_current_measure(struct psensor *s,
 
 double psensor_get_current_value(struct psensor *sensor)
 {
-       return sensor->measures[sensor->values_max_length - 1].value.d_num;
+       return sensor->measures[sensor->values_max_length - 1].value;
 }
 
 struct measure *psensor_get_current_measure(struct psensor *sensor)
@@ -304,7 +304,7 @@ double get_min_value(struct psensor **sensors, int type)
                        double t;
 
                        for (i = 0; i < sensor->values_max_length; i++) {
-                               t = sensor->measures[i].value.d_num;
+                               t = sensor->measures[i].value;
 
                                if (t == UNKNOWN_DBL_VALUE)
                                        continue;
@@ -335,7 +335,7 @@ double get_max_value(struct psensor **sensors, int type)
                        int i;
                        double t;
                        for (i = 0; i < sensor->values_max_length; i++) {
-                               t = sensor->measures[i].value.d_num;
+                               t = sensor->measures[i].value;
 
                                if (t == UNKNOWN_DBL_VALUE)
                                        continue;
index 1d4668c..18058bf 100644 (file)
@@ -39,7 +39,7 @@ measure_to_json_object(struct measure *m)
 
        json_object_object_add(o,
                               ATT_MEASURE_VALUE,
-                              json_object_new_double(m->value.d_num));
+                              json_object_new_double(m->value));
        json_object_object_add(o, ATT_MEASURE_TIME,
                               json_object_new_int((m->time).tv_sec));
        return o;
@@ -89,7 +89,7 @@ static json_object *sensor_to_json(struct psensor *s)
        mo = json_object_new_object();
        json_object_object_add(mo,
                               ATT_MEASURE_VALUE,
-                              json_object_new_double(m->value.d_num));
+                              json_object_new_double(m->value));
        json_object_object_add(mo, ATT_MEASURE_TIME,
                               json_object_new_int((m->time).tv_sec));
        json_object_object_add(obj, ATT_SENSOR_LAST_MEASURE, mo);
index d547845..0f48226 100644 (file)
@@ -36,7 +36,7 @@ static struct timeval last_notification_tv;
 void ui_notify(struct psensor *sensor, struct ui_psensor *ui)
 {
        struct timeval t;
-       char *name;
+       char *body;
        NotifyNotification *notif;
 
        log_debug("last_notification %d", last_notification_tv.tv_sec);
@@ -56,7 +56,7 @@ void ui_notify(struct psensor *sensor, struct ui_psensor *ui)
                notify_init("psensor");
 
        if (notify_is_initted() == TRUE) {
-               name = strdup(sensor->name);
+               body = strdup(sensor->name);
 
                /*
                 * Since libnotify 0.7 notify_notification_new has
@@ -64,14 +64,14 @@ void ui_notify(struct psensor *sensor, struct ui_psensor *ui)
                 */
 #if NOTIFY_CHECK_VERSION(0, 7, 0)
                notif = notify_notification_new
-                       (_("Temperature alert"), name, PSENSOR_ICON);
+                       (_("Temperature alert"), body, PSENSOR_ICON);
 #else
                notif = notify_notification_new(_("Temperature alert"),
-                                               name,
+                                               body,
                                                PSENSOR_ICON,
                                                GTK_WIDGET(ui->main_window));
 #endif
-               log_debug("notif_notification_new %s", sensor->name);
+               log_debug("notif_notification_new %s", body);
 
                notify_notification_show(notif, NULL);
 
index b4ac650..2809b51 100644 (file)
@@ -73,7 +73,7 @@ void ui_sensorlist_update(struct ui_psensor *ui)
 
                str = psensor_value_to_string(s->type,
                                              s->measures[s->values_max_length -
-                                                         1].value.d_num,
+                                                         1].value,
                                              use_celcius);
 
                gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_TEMP, str,