librpc: Use "all_zero" where appropriate
authorVolker Lendecke <vl@samba.org>
Sat, 31 Dec 2016 12:45:51 +0000 (12:45 +0000)
committerRalph Boehme <slow@samba.org>
Tue, 3 Jan 2017 15:04:28 +0000 (16:04 +0100)
... Saves a few bytes of footprint

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/librpc/crypto/gse_krb5.c

index f7aac9ebe073cc7a57e6176a867318bbc771a6aa..83afd16e7cef87861ecc2a90e248534998082fac 100644 (file)
@@ -283,13 +283,9 @@ static krb5_error_code fill_mem_keytab_from_secrets(krb5_context krbctx,
                }
        }
 
-       {
-               krb5_kt_cursor zero_csr;
-               ZERO_STRUCT(zero_csr);
-               if ((memcmp(&kt_cursor, &zero_csr, sizeof(krb5_kt_cursor)) != 0) && *keytab) {
-                       krb5_kt_end_seq_get(krbctx, *keytab, &kt_cursor);
-               }
-        }
+       if (!all_zero((uint8_t *)&kt_cursor, sizeof(kt_cursor)) && *keytab) {
+               krb5_kt_end_seq_get(krbctx, *keytab, &kt_cursor);
+       }
 
        /* keytab is not up to date, fill it up */
 
@@ -347,13 +343,9 @@ out:
        SAFE_FREE(pwd);
        SAFE_FREE(pwd_old);
 
-       {
-               krb5_kt_cursor zero_csr;
-               ZERO_STRUCT(zero_csr);
-               if ((memcmp(&kt_cursor, &zero_csr, sizeof(krb5_kt_cursor)) != 0) && *keytab) {
-                       krb5_kt_end_seq_get(krbctx, *keytab, &kt_cursor);
-               }
-        }
+       if (!all_zero((uint8_t *)&kt_cursor, sizeof(kt_cursor)) && *keytab) {
+               krb5_kt_end_seq_get(krbctx, *keytab, &kt_cursor);
+       }
 
        if (princ) {
                krb5_free_principal(krbctx, princ);
@@ -495,22 +487,12 @@ out:
 
        TALLOC_FREE(entry_princ_s);
 
-       {
-               krb5_keytab_entry zero_kt_entry;
-               ZERO_STRUCT(zero_kt_entry);
-               if (memcmp(&zero_kt_entry, &kt_entry,
-                          sizeof(krb5_keytab_entry))) {
-                       smb_krb5_kt_free_entry(krbctx, &kt_entry);
-               }
+       if (!all_zero((uint8_t *)&kt_entry, sizeof(kt_entry))) {
+               smb_krb5_kt_free_entry(krbctx, &kt_entry);
        }
 
-       {
-               krb5_kt_cursor zero_csr;
-               ZERO_STRUCT(zero_csr);
-               if ((memcmp(&kt_cursor, &zero_csr,
-                           sizeof(krb5_kt_cursor)) != 0) && keytab) {
-                       krb5_kt_end_seq_get(krbctx, keytab, &kt_cursor);
-               }
+       if (!all_zero((uint8_t *)&kt_cursor, sizeof(kt_cursor)) && keytab) {
+               krb5_kt_end_seq_get(krbctx, keytab, &kt_cursor);
        }
 
        if (keytab) {