[Ltrace-devel] [PATCH] Use err(3) instead of error(3) as more portable function
Magnus Fromreide
magfr at lysator.liu.se
Sun Sep 30 13:19:08 UTC 2012
On Sun, 2012-09-30 at 15:17 +0400, Andrey Zonov wrote:
err is BSD extensions. error is GNU extensions.
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
More information about the Ltrace-devel
mailing list