Received: from eggs.gnu.org ([2001:4830:134:3::10]:47743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVd9z-0001BE-CE for qemu-devel@nongnu.org; Fri, 05 Aug 2016 07:19:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVd9u-0005lb-5w for qemu-devel@nongnu.org; Fri, 05 Aug 2016 07:19:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVd9t-0005lF-W9 for qemu-devel@nongnu.org; Fri, 05 Aug 2016 07:19:22 -0400 From: Markus Armbruster References: <1470391392-28274-1-git-send-email-peter.maydell@linaro.org> Date: Fri, 05 Aug 2016 13:19:19 +0200 In-Reply-To: <1470391392-28274-1-git-send-email-peter.maydell@linaro.org> (Peter Maydell's message of "Fri, 5 Aug 2016 11:03:12 +0100") Message-ID: <87y44bzcnc.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain 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: Peter Maydell Cc: qemu-devel@nongnu.org, patches@linaro.org 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.