s3:winbindd: simplify winbindd_sids_to_xids_recv() a bit.
authorMichael Adam <obnox@samba.org>
Fri, 9 Nov 2012 12:54:20 +0000 (13:54 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 3 Dec 2012 07:48:20 +0000 (08:48 +0100)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/winbindd/winbindd_sids_to_xids.c

index f500f248d4ae97eae7adcaa53dcdcbe15dc224ff..f1dd4019509b1b9fc4150885e0cdd9e2bae3ed81 100644 (file)
@@ -240,62 +240,47 @@ NTSTATUS winbindd_sids_to_xids_recv(struct tevent_req *req,
 
        for (i=0; i<state->num_sids; i++) {
                char type = '\0';
-               uint32_t unix_id = UINT32_MAX;
                bool found = true;
+               struct unixid xid;
+
+               xid.id = UINT32_MAX;
 
                if (state->cached[i].sid != NULL) {
-                       unix_id = state->cached[i].xid.id;
-
-                       switch (state->cached[i].xid.type) {
-                       case ID_TYPE_UID:
-                               type = 'U';
-                               break;
-                       case ID_TYPE_GID:
-                               type = 'G';
-                               break;
-                       case ID_TYPE_BOTH:
-                               type = 'B';
-                               break;
-                       default:
-                               found = false;
-                               break;
-                       }
+                       xid = state->cached[i].xid;
                } else {
-                       struct unixid id;
-
-                       unix_id = state->ids.ids[num_non_cached].unix_id;
+                       xid.id = state->ids.ids[num_non_cached].unix_id;
+                       xid.type = state->ids.ids[num_non_cached].type;
 
-                       id.id = unix_id;
-                       id.type = state->ids.ids[num_non_cached].type;
                        idmap_cache_set_sid2unixid(
                                &state->non_cached[num_non_cached],
-                               &id);
-
-                       switch (id.type) {
-                       case ID_TYPE_UID:
-                               type = 'U';
-                               break;
-                       case ID_TYPE_GID:
-                               type = 'G';
-                               break;
-                       case ID_TYPE_BOTH:
-                               type = 'B';
-                               break;
-                       default:
-                               found = false;
-                               break;
-                       }
+                               &xid);
+
                        num_non_cached += 1;
                }
 
-               if (unix_id == UINT32_MAX) {
+               switch (xid.type) {
+               case ID_TYPE_UID:
+                       type = 'U';
+                       break;
+               case ID_TYPE_GID:
+                       type = 'G';
+                       break;
+               case ID_TYPE_BOTH:
+                       type = 'B';
+                       break;
+               default:
+                       found = false;
+                       break;
+               }
+
+               if (xid.id == UINT32_MAX) {
                        found = false;
                }
 
                if (found) {
                        result = talloc_asprintf_append_buffer(
                                result, "%c%lu\n", type,
-                               (unsigned long)unix_id);
+                               (unsigned long)xid.id);
                } else {
                        result = talloc_asprintf_append_buffer(result, "\n");
                }