diff options
Diffstat (limited to '')
-rw-r--r-- | command/groups.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/command/groups.c b/command/groups.c index cb950be..f95ee80 100644 --- a/command/groups.c +++ b/command/groups.c @@ -1,13 +1,12 @@ -#include "args.h" #include "command.h" #include "lslib.h" -#include <errno.h> #include <grp.h> #include <pwd.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <errno.h> static void help (void) { printf("Usage: groups [USER]\n\n"); @@ -34,14 +33,14 @@ COMMAND(groups) { if (errno == 0) { error("user not found"); } else { - error("failed to fetch groups: %s", strerror(errno)); + error("failed to fetch groups"); } } ngroups = 0; getgrouplist(pw->pw_name, pw->pw_gid, NULL, &ngroups); - groups = malloc(sizeof(gid_t) * ngroups); + groups = xalloc(sizeof(gid_t) * ngroups); getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups); for (i = 0; i < ngroups; i++){ @@ -49,7 +48,7 @@ COMMAND(groups) { if(gr == NULL) { free(groups); - error("failed to fetch groups: %s", strerror(errno)); + error("failed to fetch groups"); } printf("%s ",gr->gr_name); |