Skip to content

Commit

Permalink
[usb-moded] Normalize use of sizeof operator
Browse files Browse the repository at this point in the history
As 'sizeof' is not a function, do not make it look like one.

Also 'sizeof(char)' is redundant as it is 1 by definition.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Sep 5, 2018
1 parent fdc32b0 commit 94a484c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/usb_moded-config.c
Expand Up @@ -340,7 +340,7 @@ static char * config_get_kcmdline_string(const char *entry)
return(ret);
}

len = read(fd, cmdLine, sizeof(cmdLine) - 1);
len = read(fd, cmdLine, sizeof cmdLine - 1);
close(fd);

if (len <= 0)
Expand Down
2 changes: 1 addition & 1 deletion src/usb_moded-mac.c
Expand Up @@ -105,7 +105,7 @@ char * mac_read_mac(void)
fclose(g_ether);
return 0;
}
mac = malloc(sizeof(char) *17);
mac = malloc(17);
if(mac)
read = fread(mac, 1, 17, g_ether);
if(read == 17)
Expand Down
8 changes: 4 additions & 4 deletions src/usb_moded-network.c
Expand Up @@ -344,8 +344,8 @@ static int resolv_conf_dns(ipforward_data_t *ipforward)
static int network_checklink(void)
{
int ret = -1;
char dest[sizeof(UDHCP_CONFIG_PATH)+1];
size_t len = readlink(UDHCP_CONFIG_LINK, dest, sizeof(dest)-1);
char dest[sizeof UDHCP_CONFIG_PATH + 1];
size_t len = readlink(UDHCP_CONFIG_LINK, dest, sizeof dest - 1);

if (len > 0)
{
Expand Down Expand Up @@ -384,8 +384,8 @@ static int network_write_udhcpd_conf(ipforward_data_t *ipforward, mode_list_elem
}
/* generate start and end ip based on the setting */
ip = config_get_network_setting(NETWORK_IP_KEY);
ipstart = malloc(sizeof(char)*15);
ipend = malloc(sizeof(char)*15);
ipstart = malloc(15);
ipend = malloc(15);
while(i < 15)
{
if(dot < 3)
Expand Down

0 comments on commit 94a484c

Please sign in to comment.