]> arthur.ath.cx Git - ngircd.git/commitdiff
cleanups [from HEAD]
authorFlorian Westphal <fw@strlen.de>
Sat, 2 Dec 2006 13:00:25 +0000 (13:00 +0000)
committerFlorian Westphal <fw@strlen.de>
Sat, 2 Dec 2006 13:00:25 +0000 (13:00 +0000)
src/ngircd/array.c
src/ngircd/resolve.c

index 6e96bd56b0d5635324e8c04f71f41f4b4b94d66a..436738db0a96e992b563bbfbf0d9182db930dc98 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "array.h"
 
-static char UNUSED id[] = "$Id: array.c,v 1.11 2006/07/01 22:11:48 fw Exp $";
+static char UNUSED id[] = "$Id: array.c,v 1.11.2.1 2006/12/02 13:00:25 fw Exp $";
 
 #include <assert.h>
 
@@ -66,10 +66,7 @@ array_alloc(array * a, size_t size, size_t pos)
 
        assert(size > 0);
 
-       if (pos_plus1 < pos)
-               return NULL;
-
-       if (!safemult_sizet(size, pos_plus1, &alloc))
+       if (pos_plus1 == 0 || !safemult_sizet(size, pos_plus1, &alloc))
                return NULL;
 
        if (a->allocated < alloc) {
@@ -263,7 +260,7 @@ array_get(array * a, size_t membersize, size_t pos)
        if (a->allocated < totalsize)
                return NULL;
 
-       return a->mem + pos * membersize;
+       return a->mem + totalsize;
 }
 
 
@@ -283,16 +280,6 @@ array_free(array * a)
 }
 
 
-void
-array_free_wipe(array * a)
-{
-       if (!array_UNUSABLE(a))
-               memset(a->mem, 0, a->allocated);
-
-       array_free(a);
-}
-
-
 void *
 array_start(const array * const a)
 {
@@ -331,9 +318,6 @@ array_moveleft(array * a, size_t membersize, size_t pos)
        assert(a != NULL);
        assert(membersize > 0);
 
-       if (!pos)
-               return;
-
        if (!safemult_sizet(membersize, pos, &bytepos)) {
                a->used = 0;
                return;
index 7f10698d3aab9437e9f71947343753b154c37660..a145fdf39fc94bd1c9c408ad4b1c27e7e18b696c 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: resolve.c,v 1.24 2006/05/10 21:24:01 alex Exp $";
+static char UNUSED id[] = "$Id: resolve.c,v 1.24.2.1 2006/12/02 13:00:25 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -340,33 +340,24 @@ Resolve_Shutdown( RES_STAT *s)
 GLOBAL size_t
 Resolve_Read( RES_STAT *s, void* readbuf, size_t buflen)
 {
-       int err;
        ssize_t bytes_read;
 
        assert(buflen > 0);
 
        /* Read result from pipe */
-       errno = 0;
        bytes_read = read(s->resolver_fd, readbuf, buflen);
        if (bytes_read < 0) {
-               if (errno != EAGAIN) {
-                       err = errno;
-                       Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(err));
-                       Resolve_Shutdown(s);
-                       errno = err;
+               if (errno == EAGAIN)
                        return 0;
-               }
-               return 0;
-       }
 
-       Resolve_Shutdown(s);
-       if (bytes_read == 0) {  /* EOF: lookup failed */
+               Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror(errno));
+               bytes_read = 0;
+       }
 #ifdef DEBUG
+       else if (bytes_read == 0)
                Log( LOG_DEBUG, "Resolver: Can't read result: EOF");
 #endif
-               return 0;
-       }
-
+       Resolve_Shutdown(s);
        return (size_t)bytes_read;
 }
 /* -eof- */