Commit 16f8d4eb authored by Rich Salz's avatar Rich Salz Committed by Rich Salz
Browse files

memset, memcpy, sizeof consistency fixes



Just as with the OPENSSL_malloc calls, consistently use sizeof(*ptr)
for memset and memcpy.  Remove needless casts for those functions.
For memset, replace alternative forms of zero with 0.

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
parent 12048657
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -795,7 +795,7 @@ void opt_help(const OPTIONS *list)
        }

        /* Pad out prefix */
        memset(start, ' ', sizeof start - 1);
        memset(start, ' ', sizeof(start) - 1);
        start[sizeof start - 1] = '\0';

        if (o->name == OPT_MORE_STR) {
@@ -821,7 +821,7 @@ void opt_help(const OPTIONS *list)
        if ((int)(p - start) >= MAX_OPT_HELP_WIDTH) {
            *p = '\0';
            BIO_printf(bio_err, "%s\n", start);
            memset(start, ' ', sizeof start);
            memset(start, ' ', sizeof(start));
        }
        start[width] = '\0';
        BIO_printf(bio_err, "%s  %s\n", start, help);
+1 −1
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ typedef fd_mask fd_set;
# define FD_SET(n, p)    (*(p) |= (1 << ((n) % NFDBITS)))
# define FD_CLR(n, p)    (*(p) &= ~(1 << ((n) % NFDBITS)))
# define FD_ISSET(n, p)  (*(p) & (1 << ((n) % NFDBITS)))
# define FD_ZERO(p)      memset((char *)(p), 0, sizeof(*(p)))
# define FD_ZERO(p)      memset((p), 0, sizeof(*(p)))
#endif

#define PORT            4433
+5 −5
Original line number Diff line number Diff line
@@ -252,7 +252,7 @@ static int init_client_ip(int *sock, const unsigned char ip[4], int port,
    if (!ssl_sock_init())
        return (0);

    memset((char *)&them, 0, sizeof(them));
    memset(&them, 0, sizeof(them));
    them.sin_family = AF_INET;
    them.sin_port = htons((unsigned short)port);
    addr = (unsigned long)
@@ -308,7 +308,7 @@ int init_client_unix(int *sock, const char *server)
        return (0);
    }

    memset((char *)&them, 0, sizeof(them));
    memset(&them, 0, sizeof(them));
    them.sun_family = AF_UNIX;
    strcpy(them.sun_path, server);

@@ -410,7 +410,7 @@ static int init_server_long(int *sock, int port, char *ip, int type)
    if (!ssl_sock_init())
        return (0);

    memset((char *)&server, 0, sizeof(server));
    memset(&server, 0, sizeof(server));
    server.sin_family = AF_INET;
    server.sin_port = htons((unsigned short)port);
    if (ip == NULL)
@@ -475,7 +475,7 @@ static int init_server_unix(int *sock, const char *path)
    if (s == INVALID_SOCKET)
        goto err;

    memset((char *)&server, 0, sizeof(server));
    memset(&server, 0, sizeof(server));
    server.sun_family = AF_UNIX;
    strcpy(server.sun_path, path);

@@ -518,7 +518,7 @@ static int do_accept(int acc_sock, int *sock, char **host)
 redoit:
# endif

    memset((char *)&from, 0, sizeof(from));
    memset(&from, 0, sizeof(from));
    len = sizeof(from);
    /*
     * Note: under VMS with SOCKETSHR the fourth parameter is currently of
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
            errno = ENOMEM;
            return 0;
        }
        memset(*ctx, '\0', sizeof(**ctx));
        memset(*ctx, 0, sizeof(**ctx));

        (*ctx)->dir = opendir(directory);
        if ((*ctx)->dir == NULL) {
+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
            errno = ENOMEM;
            return 0;
        }
        memset(*ctx, '\0', sizeof(**ctx));
        memset(*ctx, 0, sizeof(**ctx));

        strcpy((*ctx)->filespec, directory);
        strcat((*ctx)->filespec, "*.*;");
Loading