librpc: Use switch in GUID_from_data_blob().
authorAndreas Schneider <asn@samba.org>
Mon, 7 Jun 2010 08:00:39 +0000 (10:00 +0200)
committerAndreas Schneider <asn@samba.org>
Mon, 28 Jun 2010 08:18:12 +0000 (10:18 +0200)
librpc/ndr/uuid.c

index 5b6053167a80a55b3782389583690b854d3e6e39..d46da0993d7f08fd1b9be93957d4b1fce705d1ea 100644 (file)
@@ -74,7 +74,9 @@ _PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid)
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       if (s->length == 36) {
+       switch(s->length) {
+       case 36:
+       {
                TALLOC_CTX *mem_ctx;
                const char *string;
 
@@ -90,8 +92,10 @@ _PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid)
                        status = NT_STATUS_OK;
                }
                talloc_free(mem_ctx);
-
-       } else if (s->length == 38) {
+               break;
+       }
+       case 38:
+       {
                TALLOC_CTX *mem_ctx;
                const char *string;
 
@@ -107,8 +111,10 @@ _PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid)
                        status = NT_STATUS_OK;
                }
                talloc_free(mem_ctx);
-
-       } else if (s->length == 32) {
+               break;
+       }
+       case 32:
+       {
                size_t rlen = strhex_to_str((char *)blob16.data, blob16.length,
                                            (const char *)s->data, s->length);
                if (rlen == blob16.length) {
@@ -116,10 +122,13 @@ _PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid)
                        status = NT_STATUS_OK;
                        s = &blob16;
                }
+               break;
        }
-
-       if (s->length == 16) {
+       case 16:
                return GUID_from_ndr_blob(s, guid);
+       default:
+               status = NT_STATUS_INVALID_PARAMETER;
+               break;
        }
 
        if (!NT_STATUS_IS_OK(status)) {