Don't call close() on -1
authorTor Lillqvist <tml@iki.fi>
Thu, 7 Oct 2010 09:04:52 +0000 (12:04 +0300)
committerTor Lillqvist <tml@iki.fi>
Thu, 7 Oct 2010 09:06:48 +0000 (12:06 +0300)
Of course, a proper implementation of close() will just ignore an
invalid parameter silently, and set errno. But apparently the "debug"
version of the Microsoft C library generates some noise in this
case. So avoid that. Thanks to John Emmas for reporting.

tests/testglib.c

index 7625928..b4e29f0 100644 (file)
@@ -886,7 +886,8 @@ test_file_functions (void)
   fd = g_mkstemp (template);
   if (g_test_verbose() && fd != -1)
     g_print ("g_mkstemp works even if template doesn't end in XXXXXX\n");
-  close (fd);
+  if (fd != -1)
+    close (fd);
   strcpy (template, "fooXXXXXX");
   fd = g_mkstemp (template);
   if (fd == -1)