]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Simplify smbconf_txt_load_file()
authorVolker Lendecke <vl@samba.org>
Fri, 22 Nov 2024 10:13:34 +0000 (11:13 +0100)
committerMartin Schwenke <martins@samba.org>
Mon, 2 Dec 2024 04:53:33 +0000 (04:53 +0000)
file_modtime() returns errno, so we can skip the racy file_exist()
call.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
lib/smbconf/smbconf_txt.c

index 70a35ec43049a4f4147bd9dc7248cea0ed01ade9..f090430b3486ac957bf8b4a9c48d35f4b9f8cdf6 100644 (file)
@@ -187,12 +187,12 @@ static sbcErr smbconf_txt_load_file(struct smbconf_ctx *ctx)
        int rc;
        struct timespec mt = {0};
 
-       if (!file_exist(ctx->path)) {
-               return SBC_ERR_BADFILE;
-       }
-
        rc = file_modtime(ctx->path, &mt);
        if (rc != 0) {
+               if (rc == ENOENT) {
+                       return SBC_ERR_BADFILE;
+               }
+
                /*
                 * Not worth mapping errno returned
                 * in rc to SBC_ERR_XXX. Just assume