Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Aug 2018 06:31:30 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r337959 - in stable: 10/sys/dev/hyperv/pcib 11/sys/dev/hyperv/pcib
Message-ID:  <201808170631.w7H6VUEb015045@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Fri Aug 17 06:31:30 2018
New Revision: 337959
URL: https://svnweb.freebsd.org/changeset/base/337959

Log:
  MFC r337322:
  
  Fix build of hyperv with base gcc on i386
  
  Summary:
  Base gcc fails to compile `sys/dev/hyperv/pcib/vmbus_pcib.c` for i386,
  with the following -Werror warnings:
  
  cc1: warnings being treated as errors
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'new_pcichild_device':
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:567: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'vmbus_pcib_on_channel_callback':
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:940: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'hv_pci_protocol_negotiation':
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1012: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'hv_pci_enter_d0':
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1073: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'hv_send_resources_allocated':
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1125: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'vmbus_pcib_map_msi':
  /usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1730: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  
  This is because on i386, several casts from `uint64_t` to a pointer
  reduce the value from 64 bit to 32 bit.
  
  For gcc, this can be fixed by an intermediate cast to uintptr_t. Note
  that I am assuming the incoming values will always fit into 32 bit!
  
  Differential Revision: https://reviews.freebsd.org/D15753

Modified:
  stable/11/sys/dev/hyperv/pcib/vmbus_pcib.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/sys/dev/hyperv/pcib/vmbus_pcib.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/11/sys/dev/hyperv/pcib/vmbus_pcib.c
==============================================================================
--- stable/11/sys/dev/hyperv/pcib/vmbus_pcib.c	Fri Aug 17 04:40:01 2018	(r337958)
+++ stable/11/sys/dev/hyperv/pcib/vmbus_pcib.c	Fri Aug 17 06:31:30 2018	(r337959)
@@ -564,7 +564,7 @@ new_pcichild_device(struct hv_pcibus *hbus, struct pci
 
 	ret = vmbus_chan_send(hbus->sc->chan,
 	    VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC,
-	    res_req, sizeof(*res_req), (uint64_t)&ctxt.pkt);
+	    res_req, sizeof(*res_req), (uint64_t)(uintptr_t)&ctxt.pkt);
 	if (ret)
 		goto err;
 
@@ -937,7 +937,8 @@ vmbus_pcib_on_channel_callback(struct vmbus_channel *c
 
 		switch (pkt->cph_type) {
 		case VMBUS_CHANPKT_TYPE_COMP:
-			comp_packet = (struct pci_packet *)pkt->cph_xactid;
+			comp_packet =
+			    (struct pci_packet *)(uintptr_t)pkt->cph_xactid;
 			response = (struct pci_response *)pkt;
 			comp_packet->completion_func(comp_packet->compl_ctxt,
 			    response, bytes_rxed);
@@ -1009,7 +1010,7 @@ hv_pci_protocol_negotiation(struct hv_pcibus *hbus)
 
 	ret = vmbus_chan_send(hbus->sc->chan, VMBUS_CHANPKT_TYPE_INBAND,
 	    VMBUS_CHANPKT_FLAG_RC, version_req, sizeof(*version_req),
-	    (uint64_t)&ctxt.pkt);
+	    (uint64_t)(uintptr_t)&ctxt.pkt);
 	if (ret)
 		goto out;
 
@@ -1070,7 +1071,7 @@ hv_pci_enter_d0(struct hv_pcibus *hbus)
 
 	ret = vmbus_chan_send(hbus->sc->chan, VMBUS_CHANPKT_TYPE_INBAND,
 	    VMBUS_CHANPKT_FLAG_RC, d0_entry, sizeof(*d0_entry),
-	    (uint64_t)&ctxt.pkt);
+	    (uint64_t)(uintptr_t)&ctxt.pkt);
 	if (ret)
 		goto out;
 
@@ -1122,7 +1123,8 @@ hv_send_resources_allocated(struct hv_pcibus *hbus)
 
 		ret = vmbus_chan_send(hbus->sc->chan,
 		    VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC,
-		    &pkt->message, sizeof(*res_assigned), (uint64_t)pkt);
+		    &pkt->message, sizeof(*res_assigned),
+		    (uint64_t)(uintptr_t)pkt);
 		if (ret) {
 			free_completion(&comp_pkt.host_event);
 			break;
@@ -1727,7 +1729,7 @@ vmbus_pcib_map_msi(device_t pcib, device_t child, int 
 
 	ret = vmbus_chan_send(sc->chan,	VMBUS_CHANPKT_TYPE_INBAND,
 	    VMBUS_CHANPKT_FLAG_RC, int_pkt, sizeof(*int_pkt),
-	    (uint64_t)&ctxt.pkt);
+	    (uint64_t)(uintptr_t)&ctxt.pkt);
 	if (ret) {
 		free_completion(&comp.comp_pkt.host_event);
 		return (ret);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808170631.w7H6VUEb015045>