libcls/netlogon: clang: Fix 'initialization value is never read'
authorNoel Power <noel.power@suse.com>
Wed, 10 Jul 2019 15:34:56 +0000 (16:34 +0100)
committerGary Lockyer <gary@samba.org>
Tue, 16 Jul 2019 22:52:24 +0000 (22:52 +0000)
Fixes:

libcli/netlogon/netlogon.c:183:11: warning: Value stored to 'status' during its initialization is never read <--[clang]
        NTSTATUS status = NT_STATUS_INVALID_NETWORK_RESPONSE;
                 ^~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libcli/netlogon/netlogon.c:224:11: warning: Value stored to 'status' during its initialization is never read <--[clang]
        NTSTATUS status = NT_STATUS_INVALID_NETWORK_RESPONSE;
                 ^~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.

Note: although use of default seems unecessary but gcc
(with --picky-developer) detects the possibiliy still that status
may be undefined (presumably by a non enum value leaking
into the switch)

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
libcli/netlogon/netlogon.c

index 58a331d70adaaf40f5c5308dd95d9b5a2daf4dc0..239503e85b64495192d8d964d0ebb58904da3286 100644 (file)
@@ -180,7 +180,7 @@ void map_netlogon_samlogon_response(struct netlogon_samlogon_response *response)
 NTSTATUS push_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
                                    struct nbt_netlogon_response *response)
 {
-       NTSTATUS status = NT_STATUS_INVALID_NETWORK_RESPONSE;
+       NTSTATUS status;
        enum ndr_err_code ndr_err;
        switch (response->response_type) {
        case NETLOGON_GET_PDC:
@@ -212,6 +212,9 @@ NTSTATUS push_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
                }
                status = NT_STATUS_OK;
                break;
+       default:
+               status = NT_STATUS_INVALID_NETWORK_RESPONSE;
+               break;
        }
 
        return status;
@@ -221,7 +224,7 @@ NTSTATUS push_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
 NTSTATUS pull_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
                                         struct nbt_netlogon_response *response)
 {
-       NTSTATUS status = NT_STATUS_INVALID_NETWORK_RESPONSE;
+       NTSTATUS status;
        enum netlogon_command command;
        enum ndr_err_code ndr_err;
        if (data->length < 4) {
@@ -273,6 +276,7 @@ NTSTATUS pull_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
        case LOGON_REQUEST:
        case NETLOGON_ANNOUNCE_UAS:
        case LOGON_SAM_LOGON_REQUEST:
+       default:
                status = NT_STATUS_INVALID_NETWORK_RESPONSE;
        }