s3:vfs_preopen: Change to a do-while loop and fix the check
authorAndreas Schneider <asn@samba.org>
Thu, 7 Dec 2017 17:44:59 +0000 (18:44 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 20 Mar 2018 22:16:16 +0000 (23:16 +0100)
This fixes compilation with -Wstrict-overflow=2

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/modules/vfs_preopen.c

index aac00c7be9587d55c97511c7d8e8ee755a526b35..b6a63d35b1e82ef85bf371c3ceff2ce2b8ef587a 100644 (file)
@@ -156,7 +156,7 @@ static bool preopen_helper_open_one(int sock_fd, char **pnamebuf,
 
        nread = 0;
 
-       while ((nread == 0) || (namebuf[nread-1] != '\0')) {
+       do {
                ssize_t thistime;
 
                thistime = read(sock_fd, namebuf + nread,
@@ -176,7 +176,7 @@ static bool preopen_helper_open_one(int sock_fd, char **pnamebuf,
                        }
                        *pnamebuf = namebuf;
                }
-       }
+       } while (namebuf[nread - 1] != '\0');
 
        fd = open(namebuf, O_RDONLY);
        if (fd == -1) {