From: Volker Lendecke Date: Tue, 13 Jan 2026 08:42:36 +0000 (+0100) Subject: ldb: Avoid a few memset()s with direct structs X-Git-Tag: tdb-1.4.15~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c525d164f41cd7e9b06a9a7c2ac1e484650995dd;p=thirdparty%2Fsamba.git ldb: Avoid a few memset()s with direct structs Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/lib/ldb/common/ldb_dn.c b/lib/ldb/common/ldb_dn.c index 389da444904..7596ce056f9 100644 --- a/lib/ldb/common/ldb_dn.c +++ b/lib/ldb/common/ldb_dn.c @@ -1258,9 +1258,7 @@ static struct ldb_dn_component ldb_dn_copy_component( TALLOC_CTX *mem_ctx, struct ldb_dn_component *src) { - struct ldb_dn_component dst; - - memset(&dst, 0, sizeof(dst)); + struct ldb_dn_component dst = {}; if (src == NULL) { return dst; @@ -1304,9 +1302,7 @@ static struct ldb_dn_ext_component ldb_dn_ext_copy_component( TALLOC_CTX *mem_ctx, struct ldb_dn_ext_component *src) { - struct ldb_dn_ext_component dst; - - memset(&dst, 0, sizeof(dst)); + struct ldb_dn_ext_component dst = {}; if (src == NULL) { return dst; diff --git a/lib/ldb/common/ldb_msg.c b/lib/ldb/common/ldb_msg.c index 8477ab2b00b..5c77a2ca68d 100644 --- a/lib/ldb/common/ldb_msg.c +++ b/lib/ldb/common/ldb_msg.c @@ -1603,12 +1603,11 @@ char *ldb_timestring(TALLOC_CTX *mem_ctx, time_t t) */ time_t ldb_string_to_time(const char *s) { - struct tm tm; + struct tm tm = {}; time_t t; if (s == NULL) return 0; - memset(&tm, 0, sizeof(tm)); if (sscanf(s, "%04u%02u%02u%02u%02u%02u.0Z", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { @@ -1727,11 +1726,10 @@ char *ldb_timestring_utc(TALLOC_CTX *mem_ctx, time_t t) */ time_t ldb_string_utc_to_time(const char *s) { - struct tm tm; + struct tm tm = {}; if (s == NULL) return 0; - memset(&tm, 0, sizeof(tm)); if (sscanf(s, "%02u%02u%02u%02u%02u%02uZ", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { diff --git a/lib/ldb/common/ldb_parse.c b/lib/ldb/common/ldb_parse.c index f1d224a255e..49f817771c3 100644 --- a/lib/ldb/common/ldb_parse.c +++ b/lib/ldb/common/ldb_parse.c @@ -87,8 +87,7 @@ struct ldb_val ldb_binary_decode(TALLOC_CTX *mem_ctx, const char *str) ok = hex_byte(&str[i+1], &c); if (!ok) { talloc_free(ret.data); - memset(&ret, 0, sizeof(ret)); - return ret; + return (struct ldb_val){}; } ((uint8_t *)ret.data)[j++] = c; i += 2;