libbb: add xgetgrnam too. ~0 code size change
diff --git a/libbb/bb_pwd.c b/libbb/bb_pwd.c
index 5dbc58d..d728577 100644
--- a/libbb/bb_pwd.c
+++ b/libbb/bb_pwd.c
@@ -23,7 +23,14 @@
return pw;
}
-/* xgetgrnam too? */
+struct group* FAST_FUNC xgetgrnam(const char *name)
+{
+ struct group *gr = getgrnam(name);
+ if (!gr)
+ bb_error_msg_and_die("unknown group %s", name);
+ return gr;
+}
+
struct passwd* FAST_FUNC xgetpwuid(uid_t uid)
{
@@ -89,10 +96,7 @@
{
struct group *mygroup;
- mygroup = getgrnam(name);
- if (mygroup == NULL)
- bb_error_msg_and_die("unknown group %s", name);
-
+ mygroup = xgetgrnam(name);
return mygroup->gr_gid;
}