Hola me gustaria saber si me pudieran ayudar con el siguiente error que me arroja el programa, consta de tres codigos los cuales son:
Lic2.h -> que es el header
#ifndef _LIC2_H_
#define _LIC2_H_
#define LIC_OK 0
#define LIC_NO_ADAPT_NAME_PROVIDED -1
#define LIC_INVALID_ADAPTER -2
#ifdef __cplusplus
extern "C" {
#endif
int licGetMacAddress(char * adapter, unsigned char mAddress[6]);
#ifdef __cplusplus
}
#endif
#endif /* LIC2_H_ */
Lic2.c-> que contiene las funciones a usar
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include "Lic2.h"
int licGetMacAddress(char * adapter, unsigned char mAddress[6]) {
int x, i;
int fd;
struct ifreq ifr;
char direcMac[20];
/* Initialices output variable */
memset(mAddress, 0, mAddress);
/* Validates adapter name */
if (!adapter)
return LIC_NO_ADAPT_NAME_PROVIDED;
if (!strlen(adapter))
return LIC_NO_ADAPT_NAME_PROVIDED;
/* Gets adapter's macaddress */
fd = socket(AF_INET, SOCK_DGRAM, 0);
ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name , adapter , IFNAMSIZ-1);
ioctl(fd, SIOCGIFHWADDR, &ifr);
close(fd);
memcpy(mAddress, ifr.ifr_hwaddr.sa_data, 6);
/* Verifies if adapter doesn't exist */
x = 0;
for (i = 0; i < 6; i++)
if (!mAddress[i]) x++;
if (x == 6)
return LIC_INVALID_ADAPTER;
return LIC_OK;
}
ejemplo.c --> que contiene el metodo main para ejecutar las funciones
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Lic2.h"
int main () {
int status, i;
unsigned char mAddress[6];
status=licGetMacAddress("eth0", mAddress);
if (status!=LIC_OK) {
printf("Error al obtener el Mac Address: %d \n", status);
} else {
printf("Mac Address: ");
for (i=0; i<6; i++)
printf("%02X", mAddress[i]);
printf("\n");
}
return status;
}
Al ejecutarlo claro esta en linux mediante
gcc lic2.c ejemplo.c -o getId
me arroja el siguiente error:
Lic2.c: In function ‘licGetMacAddress’:
Lic2.c:17:24: warning: passing argument 3 of ‘memset’ makes integer from pointer without a cast
memset(mAddress, 0, mAddress);
^
In file included from Lic2.c:3:0:
/usr/include/string.h:66:14: note: expected ‘size_t’ but argument is of type ‘unsigned char *’
extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
memset
. Repasa la documentación de la función.