Skip to contentSkip to conversation

libsensors: Use __func__ in

PATCH In review Andre Prendel 2 participants 3 messages Feb 20, 2009 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 libsensors: Use __func__ in

Unified sensors_fatal_error() calls. Use __func__ to get the function name.

---
 access.c     |    3 +--
 conf-parse.c |    2 +-
 data.c       |    2 +-
 general.c    |    7 +++----
 4 files changed, 6 insertions(+), 8 deletions(-)
lib/access.c +1 -2
@@ -201,8 +201,7 @@ char *sensors_get_label(const sensors_ch
 	
 sensors_get_label_exit:
 	if (!label)
-		sensors_fatal_error("sensors_get_label",
-				    "Allocating label text");
+		sensors_fatal_error(__func__, "Allocating label text");
 	return label;
 }
 
lib/conf-parse.c +1 -1
@@ -1941,7 +1941,7 @@ sensors_expr *malloc_expr(void)
 {
   sensors_expr *res = malloc(sizeof(sensors_expr));
   if (! res)
-    sensors_fatal_error("malloc_expr","Allocating a new expression");
+    sensors_fatal_error(__func__, "Allocating a new expression");
   return res;
 }
   
lib/data.c +1 -1
@@ -88,7 +88,7 @@ int sensors_parse_chip_name(const char *
 			return -SENSORS_ERR_CHIP_NAME;
 		res->prefix = strndup(name, dash - name);
 		if (!res->prefix)
-			sensors_fatal_error("sensors_parse_chip_name",
+			sensors_fatal_error(__func__,
 					    "Allocating name prefix");
 		name = dash + 1;
 	}
lib/general.c +3 -4
@@ -34,8 +34,7 @@ void sensors_malloc_array(void *list, in
 
 	*my_list = malloc(el_size*A_BUNCH);
 	if (! *my_list)
-		sensors_fatal_error("sensors_malloc_array",
-				    "Allocating new elements");
+		sensors_fatal_error(__func__, "Allocating new elements");
 	*max_el = A_BUNCH;
 	*num_el = 0;
 }
@@ -59,7 +58,7 @@ void sensors_add_array_el(const void *el
 		new_max_el = *max_el + A_BUNCH;
 		*my_list = realloc(*my_list, new_max_el * el_size);
 		if (! *my_list)
-			sensors_fatal_error("sensors_add_array_el",
+			sensors_fatal_error(__func__,
 					    "Allocating new elements");
 		*max_el = new_max_el;
 	}
@@ -77,7 +76,7 @@ void sensors_add_array_els(const void *e
 		new_max_el -= new_max_el % A_BUNCH;
 		*my_list = realloc(*my_list, new_max_el * el_size);
 		if (! *my_list)
-			sensors_fatal_error("sensors_add_array_els",
+			sensors_fatal_error(__func__,
 					    "Allocating new elements");
 		*max_el = new_max_el;
 	}

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#1 lore raw

Hi Andre,

Quoted 5 lines · Andre Prendel

Unified sensors_fatal_error() calls. Use __func__ to get the function name.

---
 access.c     |    3 +--
 conf-parse.c |    2 +-

conf-parse.c is a generated file. You must patch conf-parse.y instead.

Quoted 69 lines
 data.c       |    2 +-
 general.c    |    7 +++----
 4 files changed, 6 insertions(+), 8 deletions(-)
lib/access.c +1 -2
@@ -201,8 +201,7 @@ char *sensors_get_label(const sensors_ch
 
 sensors_get_label_exit:
 	if (!label)
-		sensors_fatal_error("sensors_get_label",
-				    "Allocating label text");
+		sensors_fatal_error(__func__, "Allocating label text");
 	return label;
 }
 
lib/conf-parse.c +1 -1
@@ -1941,7 +1941,7 @@ sensors_expr *malloc_expr(void)
 {
   sensors_expr *res = malloc(sizeof(sensors_expr));
   if (! res)
-    sensors_fatal_error("malloc_expr","Allocating a new expression");
+    sensors_fatal_error(__func__, "Allocating a new expression");
   return res;
 }
 
lib/data.c +1 -1
@@ -88,7 +88,7 @@ int sensors_parse_chip_name(const char *
 			return -SENSORS_ERR_CHIP_NAME;
 		res->prefix = strndup(name, dash - name);
 		if (!res->prefix)
-			sensors_fatal_error("sensors_parse_chip_name",
+			sensors_fatal_error(__func__,
 					    "Allocating name prefix");
 		name = dash + 1;
 	}
lib/general.c +3 -4
@@ -34,8 +34,7 @@ void sensors_malloc_array(void *list, in
 
 	*my_list = malloc(el_size*A_BUNCH);
 	if (! *my_list)
-		sensors_fatal_error("sensors_malloc_array",
-				    "Allocating new elements");
+		sensors_fatal_error(__func__, "Allocating new elements");
 	*max_el = A_BUNCH;
 	*num_el = 0;
 }
@@ -59,7 +58,7 @@ void sensors_add_array_el(const void *el
 		new_max_el = *max_el + A_BUNCH;
 		*my_list = realloc(*my_list, new_max_el * el_size);
 		if (! *my_list)
-			sensors_fatal_error("sensors_add_array_el",
+			sensors_fatal_error(__func__,
 					    "Allocating new elements");
 		*max_el = new_max_el;
 	}
@@ -77,7 +76,7 @@ void sensors_add_array_els(const void *e
 		new_max_el -= new_max_el % A_BUNCH;
 		*my_list = realloc(*my_list, new_max_el * el_size);
 		if (! *my_list)
-			sensors_fatal_error("sensors_add_array_els",
+			sensors_fatal_error(__func__,
 					    "Allocating new elements");
 		*max_el = new_max_el;
 	}
Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw
In reply to Andre Prendel
Quoted 1 line · Jean Delvare

Hi Andre,

Hello Jean,

Quoted 8 lines · Andre Prendel
Quoted 5 lines

Unified sensors_fatal_error() calls. Use __func__ to get the function name.

---
 access.c     |    3 +--
 conf-parse.c |    2 +-

conf-parse.c is a generated file. You must patch conf-parse.y instead.

thanks for the hint. I will send a new patch.

Quoted 62 lines
Quoted 62 lines
 data.c       |    2 +-
 general.c    |    7 +++----
 4 files changed, 6 insertions(+), 8 deletions(-)
lib/access.c +1 -2
@@ -201,8 +201,7 @@ char *sensors_get_label(const sensors_ch
 
 sensors_get_label_exit:
 	if (!label)
-		sensors_fatal_error("sensors_get_label",
-				    "Allocating label text");
+		sensors_fatal_error(__func__, "Allocating label text");
 	return label;
 }
 
lib/conf-parse.c +1 -1
@@ -1941,7 +1941,7 @@ sensors_expr *malloc_expr(void)
 {
   sensors_expr *res = malloc(sizeof(sensors_expr));
   if (! res)
-    sensors_fatal_error("malloc_expr","Allocating a new expression");
+    sensors_fatal_error(__func__, "Allocating a new expression");
   return res;
 }
 
lib/data.c +1 -1
@@ -88,7 +88,7 @@ int sensors_parse_chip_name(const char *
 			return -SENSORS_ERR_CHIP_NAME;
 		res->prefix = strndup(name, dash - name);
 		if (!res->prefix)
-			sensors_fatal_error("sensors_parse_chip_name",
+			sensors_fatal_error(__func__,
 					    "Allocating name prefix");
 		name = dash + 1;
 	}
lib/general.c +2 -3
@@ -34,8 +34,7 @@ void sensors_malloc_array(void *list, in
 
 	*my_list = malloc(el_size*A_BUNCH);
 	if (! *my_list)
-		sensors_fatal_error("sensors_malloc_array",
-				    "Allocating new elements");
+		sensors_fatal_error(__func__, "Allocating new elements");
 	*max_el = A_BUNCH;
 	*num_el = 0;
 }
@@ -59,7 +58,7 @@ void sensors_add_array_el(const void *el
 		new_max_el = *max_el + A_BUNCH;
 		*my_list = realloc(*my_list, new_max_el * el_size);
 		if (! *my_list)
-			sensors_fatal_error("sensors_add_array_el",
+			sensors_fatal_error(__func__,
 					    "Allocating new elements");
 		*max_el = new_max_el;
 	}
@@ -77,7 +76,7 @@ void sensors_add_array_els(const void *e
Quoted 9 lines

lib/general.c void sensors_add_array_els(const void *e · line 82

Quoted 8 lines
lib/general.c +1 -1
 		new_max_el -= new_max_el % A_BUNCH;
 		*my_list = realloc(*my_list, new_max_el * el_size);
 		if (! *my_list)
-			sensors_fatal_error("sensors_add_array_els",
+			sensors_fatal_error(__func__,
 					    "Allocating new elements");
 		*max_el = new_max_el;
 	}

Andre

Quoted 2 lines
Signature · 1 line
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors