From 88602a64b5e239c87b8020f43a8c012eaa7e7d42 Mon Sep 17 00:00:00 2001 From: night0721 Date: Fri, 20 Sep 2024 17:22:08 +0100 Subject: [PATCH] Remove use of sizeof(char) and sizeof(uint8_t) --- lib/packet.c | 4 ++-- lib/util.c | 6 +++--- src/client/db.c | 2 +- src/client/ui.c | 2 +- src/client/user.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/packet.c b/lib/packet.c index e7232fd..1ea0d99 100644 --- a/lib/packet.c +++ b/lib/packet.c @@ -246,10 +246,10 @@ int verify_packet(packet_t *pkt, int fd) */ uint8_t *create_signature(uint8_t *data, uint32_t length, secret_key *sk) { - uint8_t *signature = memalloc(SIGN_SIZE * sizeof(uint8_t)); + uint8_t *signature = memalloc(SIGN_SIZE); if (data == NULL && length == 0 && sk == NULL) { /* From server, give fake signature */ - memset(signature, 0, SIGN_SIZE * sizeof(uint8_t)); + memset(signature, 0, SIGN_SIZE); } else { uint8_t hash[HASH_SIZE]; diff --git a/lib/util.c b/lib/util.c index c976cae..4dfb391 100644 --- a/lib/util.c +++ b/lib/util.c @@ -67,7 +67,7 @@ char *replace_home(char *str) write_log(LOG_ERROR, "$HOME not defined\n"); return str; } - char *newstr = memalloc((strlen(str) + strlen(home)) * sizeof(char)); + char *newstr = memalloc(strlen(str) + strlen(home)); /* replace ~ with home */ snprintf(newstr, strlen(str) + strlen(home), "%s%s", home, str + 1); free(str); @@ -80,8 +80,8 @@ char *replace_home(char *str) */ void mkdir_p(const char *destdir) { - char *path = memalloc(PATH_MAX * sizeof(char)); - char dir_path[PATH_MAX] = ""; + char *path = memalloc(PATH_MAX); + char dir_path[PATH_MAX]; if (destdir[0] == '~') { char *home = getenv("HOME"); diff --git a/src/client/db.c b/src/client/db.c index 4b515ad..8eb7f24 100644 --- a/src/client/db.c +++ b/src/client/db.c @@ -7,7 +7,7 @@ static int callback(void *ignore, int argc, char **argv, char **azColName) { - char *username = memalloc(MAX_NAME * sizeof(char)); + char *username = memalloc(MAX_NAME); strcpy(username, argv[0]); /* Add only if it isn't talking yourself */ if (strncmp(username, USERNAME, MAX_NAME)) diff --git a/src/client/ui.c b/src/client/ui.c index 65a92f5..857b87c 100644 --- a/src/client/ui.c +++ b/src/client/ui.c @@ -198,7 +198,7 @@ void highlight_current_line() if (num_marked > 0) { /* Determine length of formatted string */ int m_len = snprintf(NULL, 0, "[%ld] selected", num_marked); - char *selected = memalloc((m_len + 1) * sizeof(char)); + char *selected = memalloc(m_len + 1); snprintf(selected, m_len + 1, "[%ld] selected", num_marked); wpprintw("(%ld/%ld) %s", current_selection + 1, users->length, selected); diff --git a/src/client/user.c b/src/client/user.c index b0bb86e..720946f 100644 --- a/src/client/user.c +++ b/src/client/user.c @@ -102,11 +102,11 @@ char *get_line(ArrayList *list, long index, bool icons) length = name_len; } - char *line = memalloc(length * sizeof(char)); + char *line = memalloc(length); line[0] = '\0'; if (icons) { - char *tmp = memalloc(9 * sizeof(char)); + char *tmp = memalloc(9); snprintf(tmp, 8, "%ls", seluser.icon); strcat(line, tmp);