From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVdks-0003iD-Uy for qemu-devel@nongnu.org; Fri, 05 Aug 2016 07:57:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVdkr-00065E-S7 for qemu-devel@nongnu.org; Fri, 05 Aug 2016 07:57:34 -0400 Received: from mail-vk0-x235.google.com ([2607:f8b0:400c:c05::235]:32829) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVdkr-000652-2T for qemu-devel@nongnu.org; Fri, 05 Aug 2016 07:57:33 -0400 Received: by mail-vk0-x235.google.com with SMTP id x130so190018302vkc.0 for ; Fri, 05 Aug 2016 04:57:32 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <87y44bzcnc.fsf@dusky.pond.sub.org> References: <1470391392-28274-1-git-send-email-peter.maydell@linaro.org> <87y44bzcnc.fsf@dusky.pond.sub.org> From: Peter Maydell Date: Fri, 5 Aug 2016 12:57:11 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH] tests/hd-geo-test: Don't pass NULL to unlink() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: QEMU Developers , Patch Tracking On 5 August 2016 at 12:19, Markus Armbruster wrote: > Peter Maydell writes: > >> The unlink() function doesn't accept a NULL pointer, so >> don't pass it one. Spotted by the clang sanitizer. >> >> Signed-off-by: Peter Maydell >> --- >> tests/hd-geo-test.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/tests/hd-geo-test.c b/tests/hd-geo-test.c >> index 12ee392..6176e81 100644 >> --- a/tests/hd-geo-test.c >> +++ b/tests/hd-geo-test.c >> @@ -416,7 +416,9 @@ int main(int argc, char **argv) >> ret = g_test_run(); >> >> for (i = 0; i < backend_last; i++) { >> - unlink(img_file_name[i]); >> + if (img_file_name[i]) { >> + unlink(img_file_name[i]); >> + } >> } >> >> return ret; > > And what terrible, terrible things unlink()'s going to do when passed a > null pointer? Turns out the same scary terrible thing it has always > done: return -1 and set errno = EFAULT. Feel free to send a bug report to the glibc folks saying they shouldn't have marked it as __nonnull((1)). thanks -- PMM