From dc2e41a16ab5c203d73bfc6e9f368820221ee3ea Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 7 Jun 2010 10:00:39 +0200 Subject: librpc: Use switch in GUID_from_data_blob(). --- librpc/ndr/uuid.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'librpc/ndr') diff --git a/librpc/ndr/uuid.c b/librpc/ndr/uuid.c index 5b6053167a..d46da0993d 100644 --- a/librpc/ndr/uuid.c +++ b/librpc/ndr/uuid.c @@ -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)) { -- cgit