Cleanup fdRead(), fdWrite() and fdSeek() a bit
authorPanu Matilainen <Panu Matilainen pmatilai@redhat.com>
Mon, 11 Jul 2011 09:37:12 +0000 (12:37 +0300)
committerPanu Matilainen <Panu Matilainen pmatilai@redhat.com>
Mon, 11 Jul 2011 09:37:12 +0000 (12:37 +0300)
- Remove unnecessary fluff, these are very simple operations
  and dont need any temporary variables, re-re-redundant NULL checking
  etc, its already done at the caller level.

rpmio/rpmio.c

index 2316db0..36c98f1 100644 (file)
@@ -402,36 +402,20 @@ FD_t fdNew(const char *descr)
 
 static ssize_t fdRead(FD_t fd, void * buf, size_t count)
 {
-    ssize_t rc;
-
-    rc = read(fdFileno(fd), buf, count);
-
-    return rc;
+    return read(fdFileno(fd), buf, count);
 }
 
 static ssize_t fdWrite(FD_t fd, const void * buf, size_t count)
 {
-    int fdno = fdFileno(fd);
-    ssize_t rc;
-
-    if (count == 0) return 0;
-
-    rc = write(fdno, buf, count);
+    if (count == 0)
+       return 0;
 
-    return rc;
+    return write(fdFileno(fd), buf, count);
 }
 
 static int fdSeek(FD_t fd, off_t pos, int whence)
 {
-    off_t p = pos;
-    off_t rc;
-
-    if (fd == NULL)
-       return -2;
-
-    rc = lseek(fdFileno(fd), p, whence);
-
-    return rc;
+    return lseek(fdFileno(fd), pos, whence);
 }
 
 static int fdClose(FD_t fd)