[SLOF] [PATCH v2] dhcp: fix warning messages when calling strtoip()

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Wed Feb 10 19:30:39 AEDT 2016


With the removal of dupicate strtoip in patch "dhcp: Remove duplicated
strtoip()" (commit 896e31da2cc260bf5311a89b63683def20329c5b), we get
following warnings messages:

dhcp.c: In function ‘dhcpv4’:
dhcp.c:215:16: warning: pointer targets in passing argument 1 of ‘strtoip’ differ in signedness [-Wpointer-sign]
   if (!strtoip(dhcp_tftp_name, (uint8_t *)&dhcp_tftp_ip)) {
                ^
In file included from dhcp.c:51:0:
../netapps/args.h:20:5: note: expected ‘const char *’ but argument is of type ‘int8_t * {aka signed char *}’
 int strtoip(const char *, char[4]);
     ^
dhcp.c:215:32: warning: pointer targets in passing argument 2 of ‘strtoip’ differ in signedness [-Wpointer-sign]
   if (!strtoip(dhcp_tftp_name, (uint8_t *)&dhcp_tftp_ip)) {
                                ^
In file included from dhcp.c:51:0:
../netapps/args.h:20:5: note: expected ‘char *’ but argument is of type ‘uint8_t * {aka unsigned char *}’
 int strtoip(const char *, char[4]);
     ^

There were unnecessary typecasts which could be removed by declaring
dhcp_tftp_name and dhcp_filename. Along with this, change the dns_get_ip
signature as well to reduce typecast.

Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
---
 clients/net-snk/app/netapps/netboot.c |  2 +-
 clients/net-snk/app/netlib/dhcp.c     | 16 ++++++++--------
 clients/net-snk/app/netlib/dns.c      |  4 ++--
 clients/net-snk/app/netlib/dns.h      |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/clients/net-snk/app/netapps/netboot.c b/clients/net-snk/app/netapps/netboot.c
index 7ed82aa..bb1db03 100644
--- a/clients/net-snk/app/netapps/netboot.c
+++ b/clients/net-snk/app/netapps/netboot.c
@@ -844,7 +844,7 @@ int parse_tftp_args(char buffer[], char *server_ip, char filename[], int fd,
 		tmp = raw + 7;
 		tmp[j] = '\0';
 		strcpy(domainname, tmp);
-		if (dns_get_ip(fd, (int8_t *)domainname, server_ip6, 6) == 0) {
+		if (dns_get_ip(fd, domainname, server_ip6, 6) == 0) {
 			printf("\n DNS failed for IPV6\n");
                         return -1;
                 }
diff --git a/clients/net-snk/app/netlib/dhcp.c b/clients/net-snk/app/netlib/dhcp.c
index 28aa488..7e2e88c 100644
--- a/clients/net-snk/app/netlib/dhcp.c
+++ b/clients/net-snk/app/netlib/dhcp.c
@@ -164,8 +164,8 @@ static uint8_t  ether_packet[ETH_MTU_SIZE];
 static uint32_t dhcp_own_ip        = 0;
 static uint32_t dhcp_server_ip     = 0;
 static uint32_t dhcp_siaddr_ip     = 0;
-static int8_t   dhcp_filename[256];
-static int8_t   dhcp_tftp_name[256];
+static char   dhcp_filename[256];
+static char   dhcp_tftp_name[256];
 static uint32_t dhcp_xid;
 
 static char   * response_buffer;
@@ -182,8 +182,8 @@ int32_t dhcpv4(char *ret_buffer, filename_ip_t *fn_ip)
 	uint32_t dhcp_tftp_ip     = 0;
 	int fd = fn_ip->fd;
 
-	strcpy((char *) dhcp_filename, "");
-	strcpy((char *) dhcp_tftp_name, "");
+	strcpy(dhcp_filename, "");
+	strcpy(dhcp_tftp_name, "");
 
 	response_buffer = ret_buffer;
 
@@ -197,11 +197,11 @@ int32_t dhcpv4(char *ret_buffer, filename_ip_t *fn_ip)
 		dhcp_siaddr_ip = fn_ip->server_ip;
 	}
 	if(fn_ip->filename[0] != 0) {
-		strcpy((char *) dhcp_filename, (char *) fn_ip->filename);
+		strcpy(dhcp_filename, (char *) fn_ip->filename);
 	}
 
 	// TFTP SERVER
-	if (!strlen((char *) dhcp_tftp_name)) {
+	if (!strlen(dhcp_tftp_name)) {
 		if (!dhcp_siaddr_ip) {
 			// ERROR: TFTP name is not presented
 			return -3;
@@ -212,7 +212,7 @@ int32_t dhcpv4(char *ret_buffer, filename_ip_t *fn_ip)
 	}
 	else {
 		// TFTP server defined by its name
-		if (!strtoip(dhcp_tftp_name, (uint8_t *)&dhcp_tftp_ip)) {
+		if (!strtoip(dhcp_tftp_name, (char *)&dhcp_tftp_ip)) {
 			if (!dns_get_ip(fd, dhcp_tftp_name, (uint8_t *)&dhcp_tftp_ip, 4)) {
 				// DNS error - can't obtain TFTP-server name
 				// Use TFTP-ip from siaddr field, if presented
@@ -230,7 +230,7 @@ int32_t dhcpv4(char *ret_buffer, filename_ip_t *fn_ip)
 	// Store configuration info into filename_ip strucutre
 	fn_ip -> own_ip = dhcp_own_ip;
 	fn_ip -> server_ip = dhcp_tftp_ip;
-	strcpy((char *) fn_ip -> filename, (char *) dhcp_filename);
+	strcpy((char *) fn_ip -> filename, dhcp_filename);
 
 	return 0;
 }
diff --git a/clients/net-snk/app/netlib/dns.c b/clients/net-snk/app/netlib/dns.c
index 0ab1346..a5a36a1 100644
--- a/clients/net-snk/app/netlib/dns.c
+++ b/clients/net-snk/app/netlib/dns.c
@@ -133,7 +133,7 @@ dns_init(uint32_t _dns_server_ip, uint8_t _dns_server_ipv6[16], uint8_t ip_versi
  *                   FALSE - error condition occurs.
  */
 int8_t
-dns_get_ip(int fd, int8_t * url, uint8_t * domain_ip, uint8_t ip_version)
+dns_get_ip(int fd, char* url, uint8_t * domain_ip, uint8_t ip_version)
 {
 	/* this counter is used so that we abort after 30 DNS request */
 	int32_t i;
@@ -143,7 +143,7 @@ dns_get_ip(int fd, int8_t * url, uint8_t * domain_ip, uint8_t ip_version)
 	(* domain_ip) = 0;
 
 	// Retrieve host name from URL
-	if (!urltohost((char *) url, (char *) host_name)) {
+	if (!urltohost(url, (char *) host_name)) {
 		printf("\nERROR:\t\t\tBad URL!\n");
 		return 0;
 	}
diff --git a/clients/net-snk/app/netlib/dns.h b/clients/net-snk/app/netlib/dns.h
index 82eea4e..b8756af 100644
--- a/clients/net-snk/app/netlib/dns.h
+++ b/clients/net-snk/app/netlib/dns.h
@@ -20,7 +20,7 @@
 extern int8_t dns_init(uint32_t _dns_server_ip, uint8_t _dns_server_ipv6[16], uint8_t ip_version);
 
 /* For given URL retrieves IPv4 from DNS-server. */
-extern int8_t dns_get_ip(int fd, int8_t * url, uint8_t * domain_ip, uint8_t ip_version);
+extern int8_t dns_get_ip(int fd, char * url, uint8_t * domain_ip, uint8_t ip_version);
 
 /* Handles DNS-packets, which are detected by receive_ether. */
 extern int32_t handle_dns(uint8_t * packet, int32_t packetsize);
-- 
2.5.0



More information about the SLOF mailing list