libads: 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/libads/kerberos_keytab.c

index 8c7c1c36d14bbadd0b064322bb4e3aca9dfecc35..3c73b089bbb1643cbe17eb33a6962cdf3947d2ca 100644 (file)
@@ -553,18 +553,10 @@ done:
        TALLOC_FREE(frame);
 
        if (context) {
-               krb5_keytab_entry zero_kt_entry;
-               krb5_kt_cursor zero_csr;
-
-               ZERO_STRUCT(zero_kt_entry);
-               ZERO_STRUCT(zero_csr);
-
-               if (memcmp(&zero_kt_entry, &kt_entry,
-                               sizeof(krb5_keytab_entry))) {
+               if (!all_zero((uint8_t *)&kt_entry, sizeof(kt_entry))) {
                        smb_krb5_kt_free_entry(context, &kt_entry);
                }
-               if ((memcmp(&cursor, &zero_csr,
-                               sizeof(krb5_kt_cursor)) != 0) && keytab) {
+               if (!all_zero((uint8_t *)&cursor, sizeof(cursor)) && keytab) {
                        krb5_kt_end_seq_get(context, keytab, &cursor);
                }
                if (keytab) {
@@ -657,21 +649,11 @@ int ads_keytab_list(const char *keytab_name)
        ZERO_STRUCT(cursor);
 out:
 
-       {
-               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(context, &kt_entry);
-               }
+       if (!all_zero((uint8_t *)&kt_entry, sizeof(kt_entry))) {
+               smb_krb5_kt_free_entry(context, &kt_entry);
        }
-       {
-               krb5_kt_cursor zero_csr;
-               ZERO_STRUCT(zero_csr);
-               if ((memcmp(&cursor, &zero_csr,
-                               sizeof(krb5_kt_cursor)) != 0) && keytab) {
-                       krb5_kt_end_seq_get(context, keytab, &cursor);
-               }
+       if (!all_zero((uint8_t *)&cursor, sizeof(cursor)) && keytab) {
+               krb5_kt_end_seq_get(context, keytab, &cursor);
        }
 
        if (keytab) {