From: Joseph Sutton Date: Fri, 1 Sep 2023 01:29:17 +0000 (+1200) Subject: s4:dsdb: Prefer explicit initialization to ZERO_STRUCT() X-Git-Tag: tevent-0.16.0~606 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd05237de4d385584b1dfc9b3b8a967f2f092820;p=thirdparty%2Fsamba.git s4:dsdb: Prefer explicit initialization to ZERO_STRUCT() Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 3e64adee2f8..46b6126dcf0 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -658,12 +658,10 @@ NTSTATUS samdb_result_passwords(TALLOC_CTX *mem_ctx, */ struct samr_LogonHours samdb_result_logon_hours(TALLOC_CTX *mem_ctx, struct ldb_message *msg, const char *attr) { - struct samr_LogonHours hours; + struct samr_LogonHours hours = {}; size_t units_per_week = 168; const struct ldb_val *val = ldb_msg_find_ldb_val(msg, attr); - ZERO_STRUCT(hours); - if (val) { units_per_week = val->length * 8; } diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 0c988ee459e..8baf5085215 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -1955,7 +1955,7 @@ static int setup_primary_samba_gpg(struct setup_password_fields_io *io, static int setup_supplemental_field(struct setup_password_fields_io *io) { struct ldb_context *ldb; - struct supplementalCredentialsBlob scb; + struct supplementalCredentialsBlob scb = {}; struct supplementalCredentialsBlob *old_scb = NULL; /* * Packages + @@ -1963,9 +1963,9 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) * WDigest, CLEARTEXT, userPassword, SambaGPG) */ uint32_t num_names = 0; - const char *names[1+NUM_PACKAGES]; + const char *names[1+NUM_PACKAGES] = {}; uint32_t num_packages = 0; - struct supplementalCredentialsPackage packages[1+NUM_PACKAGES]; + struct supplementalCredentialsPackage packages[1+NUM_PACKAGES] = {}; struct supplementalCredentialsPackage *pp = packages; int ret; enum ndr_err_code ndr_err; @@ -1974,9 +1974,6 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) bool do_samba_gpg = false; struct loadparm_context *lp_ctx = NULL; - ZERO_STRUCT(names); - ZERO_STRUCT(packages); - ldb = ldb_module_get_ctx(io->ac->module); lp_ctx = talloc_get_type(ldb_get_opaque(ldb, "loadparm"), struct loadparm_context); @@ -2326,7 +2323,6 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) *prev = *pp; *pp = temp; - ZERO_STRUCT(scb); scb.sub.signature = SUPPLEMENTAL_CREDENTIALS_SIGNATURE; scb.sub.num_packages = num_packages; scb.sub.packages = packages; @@ -3535,7 +3531,7 @@ static int setup_io(struct ph_context *ac, struct dom_sid *account_sid = NULL; int rodc_krbtgt = 0; - ZERO_STRUCTP(io); + *io = (struct setup_password_fields_io) {}; /* Some operations below require kerberos contexts */