]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
user-record-nss: make return values optional
authorLennart Poettering <lennart@poettering.net>
Tue, 14 Mar 2023 16:23:25 +0000 (17:23 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 25 Apr 2023 12:00:57 +0000 (14:00 +0200)
If we only want to know if some user ID/user name is already allocated,
we don't care for the returned data.

src/shared/user-record-nss.c

index 88b8fc2f8f5f8f43a6f1c660926fce659efd0f74..ea1bc9faac89321ed371fd691582dc90c06ab508 100644 (file)
@@ -44,7 +44,6 @@ int nss_passwd_to_user_record(
         int r;
 
         assert(pwd);
-        assert(ret);
 
         if (isempty(pwd->pw_name))
                 return -EINVAL;
@@ -161,7 +160,8 @@ int nss_passwd_to_user_record(
         hr->mask = USER_RECORD_REGULAR |
                 (!strv_isempty(hr->hashed_password) ? USER_RECORD_PRIVILEGED : 0);
 
-        *ret = TAKE_PTR(hr);
+        if (ret)
+                *ret = TAKE_PTR(hr);
         return 0;
 }
 
@@ -216,7 +216,6 @@ int nss_user_record_by_name(
         int r;
 
         assert(name);
-        assert(ret);
 
         for (;;) {
                 buf = malloc(buflen);
@@ -257,7 +256,8 @@ int nss_user_record_by_name(
         if (r < 0)
                 return r;
 
-        (*ret)->incomplete = incomplete;
+        if (ret)
+                (*ret)->incomplete = incomplete;
         return 0;
 }
 
@@ -273,8 +273,6 @@ int nss_user_record_by_uid(
         struct spwd spwd, *sresult = NULL;
         int r;
 
-        assert(ret);
-
         for (;;) {
                 buf = malloc(buflen);
                 if (!buf)
@@ -313,7 +311,8 @@ int nss_user_record_by_uid(
         if (r < 0)
                 return r;
 
-        (*ret)->incomplete = incomplete;
+        if (ret)
+                (*ret)->incomplete = incomplete;
         return 0;
 }
 
@@ -326,7 +325,6 @@ int nss_group_to_group_record(
         int r;
 
         assert(grp);
-        assert(ret);
 
         if (isempty(grp->gr_name))
                 return -EINVAL;
@@ -376,7 +374,8 @@ int nss_group_to_group_record(
         g->mask = USER_RECORD_REGULAR |
                 (!strv_isempty(g->hashed_password) ? USER_RECORD_PRIVILEGED : 0);
 
-        *ret = TAKE_PTR(g);
+        if (ret)
+                *ret = TAKE_PTR(g);
         return 0;
 }
 
@@ -431,7 +430,6 @@ int nss_group_record_by_name(
         int r;
 
         assert(name);
-        assert(ret);
 
         for (;;) {
                 buf = malloc(buflen);
@@ -471,7 +469,8 @@ int nss_group_record_by_name(
         if (r < 0)
                 return r;
 
-        (*ret)->incomplete = incomplete;
+        if (ret)
+                (*ret)->incomplete = incomplete;
         return 0;
 }
 
@@ -487,8 +486,6 @@ int nss_group_record_by_gid(
         struct sgrp sgrp, *sresult = NULL;
         int r;
 
-        assert(ret);
-
         for (;;) {
                 buf = malloc(buflen);
                 if (!buf)
@@ -526,6 +523,7 @@ int nss_group_record_by_gid(
         if (r < 0)
                 return r;
 
-        (*ret)->incomplete = incomplete;
+        if (ret)
+                (*ret)->incomplete = incomplete;
         return 0;
 }