about summary refs log tree commit diff
path: root/libio/fmemopen.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-09-01 21:16:28 +0000
committerUlrich Drepper <drepper@redhat.com>2000-09-01 21:16:28 +0000
commitc6cc2207a5d90e521aed37cd511c6fb2e0b656c2 (patch)
tree386ea9f31be021b46e4519076deab80a6710d2a6 /libio/fmemopen.c
parent4c7d276eb123523c66c1d8cbf7dbb10fac674cd2 (diff)
downloadglibc-c6cc2207a5d90e521aed37cd511c6fb2e0b656c2.tar.gz
glibc-c6cc2207a5d90e521aed37cd511c6fb2e0b656c2.tar.xz
glibc-c6cc2207a5d90e521aed37cd511c6fb2e0b656c2.zip
Update.
2000-09-01  Ulrich Drepper  <drepper@redhat.com>

	* libio/fmemopen.c (fmemopen_seek): Add default case in switch
	statement.  General cleanup.
Diffstat (limited to 'libio/fmemopen.c')
-rw-r--r--libio/fmemopen.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/libio/fmemopen.c b/libio/fmemopen.c
index d98b671793..bf996d4058 100644
--- a/libio/fmemopen.c
+++ b/libio/fmemopen.c
@@ -93,7 +93,7 @@ fmemopen_read (void *cookie, char *b, size_t s)
 
   c = (fmemopen_cookie_t *) cookie;
 
-  if ((c->pos + s) > c->size)
+  if (c->pos + s > c->size)
     {
       if (c->pos == c->size)
 	return -1;
@@ -118,11 +118,11 @@ fmemopen_write (void *cookie, const char *b, size_t s)
 
   c = (fmemopen_cookie_t *) cookie;
 
-  addnullc = ((s == 0) || (b[s - 1] != '\0')) ? 1 : 0;
+  addnullc = s == 0 || b[s - 1] != '\0';
 
-  if ((c->pos + s + addnullc) > c->size)
+  if (c->pos + s + addnullc > c->size)
     {
-      if ((c->pos + addnullc) == c->size)
+      if (c->pos + addnullc == c->size)
 	return -1;
       s = c->size - c->pos - addnullc;
     }
@@ -151,7 +151,6 @@ fmemopen_seek (void *cookie, _IO_off64_t * p, int w)
 
   switch (w)
     {
-
     case SEEK_SET:
       np = *p;
       break;
@@ -164,9 +163,11 @@ fmemopen_seek (void *cookie, _IO_off64_t * p, int w)
       np = c->size - *p;
       break;
 
+    default:
+      return -1;
     }
 
-  if ((np < 0) || (np > c->size))
+  if (np < 0 || np > c->size)
     return -1;
 
   c->pos = np;
@@ -182,8 +183,7 @@ fmemopen_close (void *cookie)
 
   c = (fmemopen_cookie_t *) cookie;
 
-  if (c->mybuffer)
-    free (c->buffer);
+  free (c->buffer);
   free (c);
 
   return 0;
@@ -213,9 +213,7 @@ fmemopen (void *buf, size_t len, const char *mode)
       c->buffer[0] = '\0';
     }
   else
-    {
-      c->buffer = buf;
-    }
+    c->buffer = buf;
 
   c->size = len;
 
@@ -225,13 +223,9 @@ fmemopen (void *buf, size_t len, const char *mode)
   c->maxpos = strlen (c->buffer);
 
   if (mode[0] == 'a')
-    {
-      c->pos = c->maxpos;
-    }
+    c->pos = c->maxpos;
   else
-    {
-      c->pos = 0;
-    }
+    c->pos = 0;
 
   iof.read = fmemopen_read;
   iof.write = fmemopen_write;