From: Joseph Sutton Date: Tue, 5 Sep 2023 22:54:25 +0000 (+1200) Subject: ldb: Prefer explicit initialization to ZERO_STRUCT() X-Git-Tag: tevent-0.16.0~564 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=477dc8f2467500a771fef88521d9f4163af11d89;p=thirdparty%2Fsamba.git ldb: Prefer explicit initialization to ZERO_STRUCT() Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/lib/ldb/common/ldb_msg.c b/lib/ldb/common/ldb_msg.c index a9f59006173..afddbe40ef6 100644 --- a/lib/ldb/common/ldb_msg.c +++ b/lib/ldb/common/ldb_msg.c @@ -346,7 +346,7 @@ static int _ldb_msg_add_el(struct ldb_message *msg, return LDB_ERR_OPERATIONS_ERROR; } - ZERO_STRUCT(els[msg->num_elements]); + els[msg->num_elements] = (struct ldb_message_element) {}; msg->elements = els; msg->num_elements++; @@ -848,7 +848,7 @@ int ldb_msg_find_attr_as_int(const struct ldb_message *msg, int default_value) { const struct ldb_val *v = ldb_msg_find_ldb_val(msg, attr_name); - char buf[sizeof("-2147483648")]; + char buf[sizeof("-2147483648")] = {}; char *end = NULL; int ret; @@ -856,7 +856,6 @@ int ldb_msg_find_attr_as_int(const struct ldb_message *msg, return default_value; } - ZERO_STRUCT(buf); if (v->length >= sizeof(buf)) { return default_value; } @@ -878,7 +877,7 @@ unsigned int ldb_msg_find_attr_as_uint(const struct ldb_message *msg, unsigned int default_value) { const struct ldb_val *v = ldb_msg_find_ldb_val(msg, attr_name); - char buf[sizeof("-2147483648")]; + char buf[sizeof("-2147483648")] = {}; char *end = NULL; unsigned int ret; @@ -886,7 +885,6 @@ unsigned int ldb_msg_find_attr_as_uint(const struct ldb_message *msg, return default_value; } - ZERO_STRUCT(buf); if (v->length >= sizeof(buf)) { return default_value; } @@ -919,7 +917,7 @@ int64_t ldb_msg_find_attr_as_int64(const struct ldb_message *msg, int ldb_val_as_int64(const struct ldb_val *v, int64_t *val) { - char buf[sizeof("-9223372036854775808")]; + char buf[sizeof("-9223372036854775808")] = {}; char *end = NULL; int64_t result; @@ -927,7 +925,6 @@ int ldb_val_as_int64(const struct ldb_val *v, int64_t *val) return LDB_ERR_OPERATIONS_ERROR; } - ZERO_STRUCT(buf); if (v->length >= sizeof(buf)) { return LDB_ERR_OPERATIONS_ERROR; } @@ -958,7 +955,7 @@ uint64_t ldb_msg_find_attr_as_uint64(const struct ldb_message *msg, int ldb_val_as_uint64(const struct ldb_val *v, uint64_t *val) { - char buf[sizeof("-9223372036854775808")]; + char buf[sizeof("-9223372036854775808")] = {}; char *end = NULL; uint64_t result; @@ -966,7 +963,6 @@ int ldb_val_as_uint64(const struct ldb_val *v, uint64_t *val) return LDB_ERR_OPERATIONS_ERROR; } - ZERO_STRUCT(buf); if (v->length >= sizeof(buf)) { return LDB_ERR_OPERATIONS_ERROR; }