D
Daniel Rudy
Hello Everyone,
How do I return early from a void function? The following code
does not compile.
strata:/home/dr2867/c/modules 735 $$$ ->./compile unpifi.c unpifi
gcc -W -Wall -Wshadow -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wnested-externs -Wwrite-strings -Wflo
at-equal -Winline -Wtrigraphs -ansi -std=c89 -pedantic -ggdb3 -lc -o unpifi unpifi.c
unpifi.c: In function `ifi_link_address':
unpifi.c:146: error: syntax error before ')' token
unpifi.c:146: warning: `return' with a value, in function returning void
unpifi.c:150: error: syntax error before ')' token
unpifi.c:150: warning: `return' with a value, in function returning void
strata:/home/dr2867/c/modules 736 $$$ ->
/* convert ethernet hardware address to a human readable
form.
internal holding buffer is 32 bytes.
*dest - pointer to result buffer.
*src - pointer to binary address.
size - size of binary address. 6 or 8 */
void ifi_link_address(char *dest, uchar *src, int size)
{
uchar *ptr;
int i;
char buff1[32];
char buff2[32];
/* check for input errors */
if (dest == NULL) return();
if (src == NULL)
{
dest[0] = '\0';
return();
}
if ((i = size) > 0)
{
ptr = src;
bzero(buff1, sizeof(buff1));
bzero(buff2, sizeof(buff2));
do
{
snprintf(buff1, sizeof(buff1), "%s%02x", (i == size) ? " " : ":", *ptr++);
strlcat(buff2, buff1, sizeof(buff1));
} while (--i > 0);
memcpy(dest, buff2, strlen(buff2) + 1);
}
else dest[0] = '\0';
}
--
Daniel Rudy
Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m
Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
How do I return early from a void function? The following code
does not compile.
strata:/home/dr2867/c/modules 735 $$$ ->./compile unpifi.c unpifi
gcc -W -Wall -Wshadow -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wnested-externs -Wwrite-strings -Wflo
at-equal -Winline -Wtrigraphs -ansi -std=c89 -pedantic -ggdb3 -lc -o unpifi unpifi.c
unpifi.c: In function `ifi_link_address':
unpifi.c:146: error: syntax error before ')' token
unpifi.c:146: warning: `return' with a value, in function returning void
unpifi.c:150: error: syntax error before ')' token
unpifi.c:150: warning: `return' with a value, in function returning void
strata:/home/dr2867/c/modules 736 $$$ ->
/* convert ethernet hardware address to a human readable
form.
internal holding buffer is 32 bytes.
*dest - pointer to result buffer.
*src - pointer to binary address.
size - size of binary address. 6 or 8 */
void ifi_link_address(char *dest, uchar *src, int size)
{
uchar *ptr;
int i;
char buff1[32];
char buff2[32];
/* check for input errors */
if (dest == NULL) return();
if (src == NULL)
{
dest[0] = '\0';
return();
}
if ((i = size) > 0)
{
ptr = src;
bzero(buff1, sizeof(buff1));
bzero(buff2, sizeof(buff2));
do
{
snprintf(buff1, sizeof(buff1), "%s%02x", (i == size) ? " " : ":", *ptr++);
strlcat(buff2, buff1, sizeof(buff1));
} while (--i > 0);
memcpy(dest, buff2, strlen(buff2) + 1);
}
else dest[0] = '\0';
}
--
Daniel Rudy
Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m
Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep