From: Jennifer Sutton Date: Thu, 20 Feb 2025 00:41:48 +0000 (+1300) Subject: ldb: Fix maybe-uninitialized warning X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7f59566ae1b742ec126822d49d6b781e612051d;p=thirdparty%2Fsamba.git ldb: Fix maybe-uninitialized warning In file included from ../../lib/ldb/include/ldb.h:50, from ../../lib/ldb/include/ldb_private.h:43, from ../../lib/ldb/common/ldb_pack.c:34: ../../lib/ldb/common/ldb_pack.c: In function ‘ldb_filter_attrs’: ../../lib/talloc/talloc.h:1173:48: error: ‘i’ may be used uninitialized [-Werror=maybe-uninitialized] 1173 | #define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../lib/ldb/common/ldb_pack.c:1178:34: note: in expansion of macro ‘talloc_array’ 1178 | filtered_msg->elements = talloc_array(filtered_msg, | ^~~~~~~~~~~~ ../../lib/ldb/common/ldb_pack.c:1134:22: note: ‘i’ was declared here 1134 | unsigned int i; | ^ cc1: all warnings being treated as errors Signed-off-by: Jennifer Sutton Reviewed-by: Douglas Bagnall --- diff --git a/lib/ldb/common/ldb_pack.c b/lib/ldb/common/ldb_pack.c index 409be590611..86701ad7e71 100644 --- a/lib/ldb/common/ldb_pack.c +++ b/lib/ldb/common/ldb_pack.c @@ -1131,7 +1131,7 @@ int ldb_filter_attrs(struct ldb_context *ldb, const char *const *attrs, struct ldb_message *filtered_msg) { - unsigned int i; + unsigned int i = 0; bool keep_all = false; bool add_dn = false; uint32_t num_elements;