Remove use of sizeof(char) and sizeof(uint8_t)

This commit is contained in:
Night Kaly 2024-09-20 17:22:08 +01:00
parent 90f971133b
commit 88602a64b5
Signed by: night0721
GPG key ID: 957D67B8DB7A119B
5 changed files with 9 additions and 9 deletions

View file

@ -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];

View file

@ -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");

View file

@ -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))

View file

@ -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);

View file

@ -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);