]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb: Avoid a few memset()s with direct structs
authorVolker Lendecke <vl@samba.org>
Tue, 13 Jan 2026 08:42:36 +0000 (09:42 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 20 Jan 2026 11:53:34 +0000 (11:53 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
lib/ldb/common/ldb_dn.c
lib/ldb/common/ldb_msg.c
lib/ldb/common/ldb_parse.c

index 389da4449044ef5848673718cb2ae813a01519b3..7596ce056f95f966423a0946d14eee5e167347ac 100644 (file)
@@ -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;
index 8477ab2b00be68d1e5972f5c65541bf75ab53939..5c77a2ca68d3ae70b9a576e52ba6a65f6b53e230 100644 (file)
@@ -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) {
index f1d224a255e4ec9ff3febf921fb2a9c68b40ce12..49f817771c3d93144eabae6ebcee2bd3fee4167e 100644 (file)
@@ -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;