Skip to contentSkip to conversation

libsensors: Use __func__ in

PATCH In review Andre Prendel 2 participants 4 messages Feb 23, 2009 – Mar 2, 2009 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 libsensors: Use __func__ in

Hi Jean,

this is an updated version of the patch from 20.02. According to your hint I have patched conf-parse.y and not conf-parse.c.

This patch unifies sensors_fatal_error() calls. Uses __func__ to get the function name.

Andre

---
 access.c     |    3 +--
 conf-parse.y |    3 +--
 data.c       |    2 +-
 general.c    |    7 +++----
 4 files changed, 6 insertions(+), 9 deletions(-)
lib/access.c +1 -2
diff -urp lm-sensors-dev/lib/access.c my-sensors/lib/access.c
@@ -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.y +1 -2
diff -urp lm-sensors-dev/lib/conf-parse.y my-sensors/lib/conf-parse.y
@@ -342,7 +342,6 @@ 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
diff -urp lm-sensors-dev/lib/data.c my-sensors/lib/data.c
@@ -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
diff -urp lm-sensors-dev/lib/general.c my-sensors/lib/general.c
@@ -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 77 lines · Andre Prendel

Hi Jean,

this is an updated version of the patch from 20.02. According to your hint I have patched conf-parse.y and not conf-parse.c.

This patch unifies sensors_fatal_error() calls. Uses __func__ to get the function name.

Andre

---
 access.c     |    3 +--
 conf-parse.y |    3 +--
 data.c       |    2 +-
 general.c    |    7 +++----
 4 files changed, 6 insertions(+), 9 deletions(-)

diff -urp lm-sensors-dev/lib/access.c my-sensors/lib/access.c

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;
 }
 

diff -urp lm-sensors-dev/lib/conf-parse.y my-sensors/lib/conf-parse.y

lib/conf-parse.y +1 -2
@@ -342,7 +342,6 @@ 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;
 }
-  

diff -urp lm-sensors-dev/lib/data.c my-sensors/lib/data.c

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;
 	}

diff -urp lm-sensors-dev/lib/general.c my-sensors/lib/general.c

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;
 	}

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

Quoted 8 lines
lib/general.c +1 -1
@@ -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;
 	}

Patch looks good, however I can't apply it right now because SVN is frozen for the release of lm-sensors 3.1.0 at the end of the week. Your patch will be applied after the release.

BTW, are you sure you don't want an SVN account? You're sending good patches, and you might as well apply them yourself...

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 9 lines · Andre Prendel
Quoted 2 lines · Jean Delvare

BTW, are you sure you don't want an SVN account? You're sending good patches, and you might as well apply them yourself...

How works patch reviewing in that case? Should I send the patches still to the list? I don't want to break something or do silly things.

So if we don't lose the reviewing I would be very happy to get an account.

We don't lose anything. You still send the patches to the list for review, and once the review is positive, you get to commit the patches yourself. The only difference is who runs "svn commit".

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#3 lore raw
In reply to Andre Prendel

Andre,

Quoted 6 lines · Andre Prendel
Quoted 3 lines · Jean Delvare

We don't lose anything. You still send the patches to the list for review, and once the review is positive, you get to commit the patches yourself. The only difference is who runs "svn commit".

So let's do it. :)

The 3.1.0 release is done, so you can apply your patch now.

Signature · 6 lines
Jean Delvare

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