[IMPROVE] remove unnecessary file descriptor checking
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Fri, 9 Aug 2013 07:34:46 +0000 (11:34 +0400)
committerVitaliy Cherepanov <v.cherepanov@samsung.com>
Fri, 9 Aug 2013 07:34:46 +0000 (11:34 +0400)
daemon/sys_stat.c

index f5ce71d..b1869a5 100644 (file)
@@ -118,20 +118,18 @@ int get_file_status_no_open(int pfd, const char *filename)
 #ifndef LOCALTEST
        char buf[STATUS_STRING_MAX];
 
-       if (likely(pfd != NULL)) {
-               if (unlikely(pfd < 0)) {
-                       // file is not open
-                       return 0;
-               }
+       if (unlikely(pfd < 0)) {
+               // file is not open
+               return 0;
+       }
 
-               lseek(pfd, 0, SEEK_SET);        // rewind to start of file
+       lseek(pfd, 0, SEEK_SET);        // rewind to start of file
 
-               // read from file
-               if (unlikely(read(pfd, buf, STATUS_STRING_MAX) == -1))
-                       status =  -(errno);
-               else
-                       status = atoi(buf);
-       }
+       // read from file
+       if (unlikely(read(pfd, buf, STATUS_STRING_MAX) == -1))
+               status =  -(errno);
+       else
+               status = atoi(buf);
 #endif
 
        return status;