]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli: README.Coding for dom_sid routines
authorVolker Lendecke <vl@samba.org>
Tue, 26 Nov 2024 17:02:34 +0000 (18:02 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 3 Dec 2024 08:01:30 +0000 (08:01 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
libcli/security/dom_sid.c

index 21012b70884c23253286037a914c78894f5e6377..04ac6e4cf539eeb492d599c3968b4b7a0e7048a7 100644 (file)
@@ -39,20 +39,27 @@ int dom_sid_compare_auth(const struct dom_sid *sid1,
 {
        int i;
 
-       if (sid1 == sid2)
+       if (sid1 == sid2) {
                return 0;
-       if (!sid1)
+       }
+
+       if (sid1 == NULL) {
                return -1;
-       if (!sid2)
+       }
+
+       if (sid2 == NULL) {
                return 1;
+       }
 
-       if (sid1->sid_rev_num != sid2->sid_rev_num)
+       if (sid1->sid_rev_num != sid2->sid_rev_num) {
                return NUMERIC_CMP(sid1->sid_rev_num, sid2->sid_rev_num);
+       }
 
-       for (i = 0; i < 6; i++)
+       for (i = 0; i < 6; i++) {
                if (sid1->id_auth[i] != sid2->id_auth[i]) {
                        return NUMERIC_CMP(sid1->id_auth[i], sid2->id_auth[i]);
                }
+       }
 
        return 0;
 }
@@ -65,12 +72,17 @@ int dom_sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2)
 {
        int i;
 
-       if (sid1 == sid2)
+       if (sid1 == sid2) {
                return 0;
-       if (!sid1)
+       }
+
+       if (sid1 == NULL) {
                return -1;
-       if (!sid2)
+       }
+
+       if (sid2 == NULL) {
                return 1;
+       }
 
        /* Compare most likely different rids, first: i.e start at end */
        if (sid1->num_auths != sid2->num_auths) {