[Ltrace-devel] [PATCH] Use err(3) instead of error(3) as more portable function

Andrey Zonov zont at FreeBSD.org
Sun Sep 30 14:56:32 UTC 2012


On 9/30/12 5:19 PM, Magnus Fromreide wrote:
> On Sun, 2012-09-30 at 15:17 +0400, Andrey Zonov wrote:
> 
> err is BSD extensions. error is GNU extensions.
> 

err(3) are in BSD libc and in glibc. error(3) is only in glibc.

> If you want portability then I think fprintf + exit is the way to go.
> 
> /MF
> 
>> ---
>>  expr.c             |    4 ++--
>>  read_config_file.c |    4 ++--
>>  zero.c             |    4 ++--
>>  3 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/expr.c b/expr.c
>> index c0ebcef..ff249b1 100644
>> --- a/expr.c
>> +++ b/expr.c
>> @@ -20,8 +20,8 @@
>>
>>  #include <string.h>
>>  #include <assert.h>
>> +#include <err.h>
>>  #include <errno.h>
>> -#include <error.h>
>>  #include <stdlib.h>
>>
>>  #include "expr.h"
>> @@ -330,7 +330,7 @@ expr_self(void)
>>  	if (node == NULL) {
>>  		node = malloc(sizeof(*node));
>>  		if (node == NULL)
>> -			error(1, errno, "malloc expr_self");
>> +			err(1, "malloc expr_self");
>>  		expr_init_self(node);
>>  	}
>>  	return node;
>> diff --git a/read_config_file.c b/read_config_file.c
>> index 87e87e7..d761f93 100644
>> --- a/read_config_file.c
>> +++ b/read_config_file.c
>> @@ -26,8 +26,8 @@
>>  #include <string.h>
>>  #include <stdlib.h>
>>  #include <ctype.h>
>> +#include <err.h>
>>  #include <errno.h>
>> -#include <error.h>
>>  #include <assert.h>
>>
>>  #include "common.h"
>> @@ -1103,7 +1103,7 @@ init_global_config(void)
>>  {
>>  	struct arg_type_info *info = malloc(2 * sizeof(*info));
>>  	if (info == NULL)
>> -		error(1, errno, "malloc in init_global_config");
>> +		err(1, "malloc in init_global_config");
>>
>>  	memset(info, 0, 2 * sizeof(*info));
>>  	info[0].type = ARGTYPE_POINTER;
>> diff --git a/zero.c b/zero.c
>> index bc119ee..3639361 100644
>> --- a/zero.c
>> +++ b/zero.c
>> @@ -18,7 +18,7 @@
>>   * 02110-1301 USA
>>   */
>>
>> -#include <error.h>
>> +#include <err.h>
>>  #include <errno.h>
>>
>>  #include "zero.h"
>> @@ -97,7 +97,7 @@ expr_node_zero(void)
>>  	if (node == NULL) {
>>  		node = malloc(sizeof(*node));
>>  		if (node == NULL)
>> -			error(1, errno, "malloc expr_node_zero");
>> +			err(1, "malloc expr_node_zero");
>>  		expr_init_cb1(node, &zero1_callback,
>>  			      expr_self(), 0, (void *)-1);
>>  	}
>> _______________________________________________
>> Ltrace-devel mailing list
>> Ltrace-devel at lists.alioth.debian.org
>> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/ltrace-devel
> 
> 


-- 
Andrey Zonov

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 535 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/ltrace-devel/attachments/20120930/19b6103c/attachment.pgp>


More information about the Ltrace-devel mailing list