File: 06_correct_test_open_syscall

package info (click to toggle)
chntpw 140201-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,100 kB
  • sloc: ansic: 23,909; makefile: 137
file content (20 lines) | stat: -rw-r--r-- 779 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Description: Fix code in source
  Fix code that probably is never run since the existing code is totally bogus.
  The condition, !open(...), will almost always be true.  (sole exception is
  when starting a program with stdin initially closed)

Forwarded: no
Author: Jim Meyering <meyering@redhat.com>
Last-Update: Mon, 20 Jul 2009 21:05:44 +0200

--- a/ntreg.c
+++ b/ntreg.c
@@ -4133,7 +4133,7 @@
   if ( !(hdesc->state & HMODE_DIRTY)) return(0);
 
   if ( !(hdesc->state & HMODE_OPEN)) { /* File has been closed */
-    if (!(hdesc->filedesc = open(hdesc->filename,O_RDWR))) {
+    if ((hdesc->filedesc = open(hdesc->filename,O_RDWR)) < 0) {
       fprintf(stderr,"writeHive: open(%s) failed: %s, FILE NOT WRITTEN!\n",hdesc->filename,strerror(errno));
       return(1);
     }