From 530ff00378e7fc235e5ea51067c77398d575141e Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 30 Oct 2012 08:00:53 +0000 Subject: Teach pw(8) about how to use pw/gr API to reduce code duplication MFC after: 2 months --- pw/pw_group.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pw/pw_group.c') diff --git a/pw/pw_group.c b/pw/pw_group.c index a8f182c..f4f2116 100644 --- a/pw/pw_group.c +++ b/pw/pw_group.c @@ -34,6 +34,8 @@ static const char rcsid[] = #include #include #include +#include +#include #include "pw.h" #include "bitmap.h" @@ -403,10 +405,9 @@ static int print_group(struct group * grp, int pretty) { if (!pretty) { - int buflen = 0; char *buf = NULL; - fmtgrent(&buf, &buflen, grp); + buf = gr_make(grp); fputs(buf, stdout); free(buf); } else { -- cgit v1.2.3-56-ge451 From 4ab1204d48d11e3671dceb65e745429ff5ee1f9d Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Wed, 5 Dec 2012 13:56:43 +0000 Subject: Remove useless check for NULL prior to free. Approved by: cperciva MFC after: 2 weeks --- pw/bitmap.c | 3 +-- pw/pw_group.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'pw/pw_group.c') diff --git a/pw/bitmap.c b/pw/bitmap.c index bcfea7e..8e96bff 100644 --- a/pw/bitmap.c +++ b/pw/bitmap.c @@ -50,8 +50,7 @@ bm_alloc(int size) void bm_dealloc(struct bitmap * bm) { - if (bm->map) - free(bm->map); + free(bm->map); } static void diff --git a/pw/pw_group.c b/pw/pw_group.c index f4f2116..fda62b2 100644 --- a/pw/pw_group.c +++ b/pw/pw_group.c @@ -274,8 +274,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args) pw_log(cnf, mode, W_GROUP, "%s(%ld)", grp->gr_name, (long) grp->gr_gid); - if (members) - free(members); + free(members); return EXIT_SUCCESS; } -- cgit v1.2.3-56-ge451 From 74e95384fa757248d2615bbf644d34d2d5019855 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Thu, 27 Dec 2012 14:44:13 +0000 Subject: Fix a regression in "pw group show" introduced r242349: print a newline after printing each group line. PR: bin/174731 Submitted by: Jan Beich --- pw/pw_group.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pw/pw_group.c') diff --git a/pw/pw_group.c b/pw/pw_group.c index fda62b2..3259412 100644 --- a/pw/pw_group.c +++ b/pw/pw_group.c @@ -407,7 +407,7 @@ print_group(struct group * grp, int pretty) char *buf = NULL; buf = gr_make(grp); - fputs(buf, stdout); + printf("%s\n", buf); free(buf); } else { int i; -- cgit v1.2.3-56-ge451