git: f728bcf204ee - stable/12 - [nvmecontrol] Fix type signedness warning-to-error on gcc-6.4

Ryan Libby rlibby at FreeBSD.org
Tue Dec 29 23:06:44 UTC 2020


The branch stable/12 has been updated by rlibby:

URL: https://cgit.FreeBSD.org/src/commit/?id=f728bcf204ee0e956c54ed896141e3469a8f62a7

commit f728bcf204ee0e956c54ed896141e3469a8f62a7
Author:     Adrian Chadd <adrian at FreeBSD.org>
AuthorDate: 2020-11-17 17:12:28 +0000
Commit:     Ryan Libby <rlibby at FreeBSD.org>
CommitDate: 2020-12-29 23:04:40 +0000

    [nvmecontrol] Fix type signedness warning-to-error on gcc-6.4
    
    This fixes a type signedness comparison warning-to-error on
    gcc-6.4. The ternary operation casts it right but the actual
    assignment doesn't.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D26791
    
    (cherry picked from commit 44c52406ced4cbba704f9bec588a8238d5a5ef32)
---
 sbin/nvmecontrol/firmware.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sbin/nvmecontrol/firmware.c b/sbin/nvmecontrol/firmware.c
index ec7e54afc57e..e6ebc9b70321 100644
--- a/sbin/nvmecontrol/firmware.c
+++ b/sbin/nvmecontrol/firmware.c
@@ -159,8 +159,9 @@ static void
 update_firmware(int fd, uint8_t *payload, int32_t payload_size, uint8_t fwug)
 {
 	struct nvme_pt_command	pt;
-	uint64_t                max_xfer_size;
-	int32_t			off, resid, size;
+	uint64_t		max_xfer_size;
+	int32_t			off;
+	uint32_t		resid, size;
 	void			*chunk;
 
 	off = 0;
@@ -175,8 +176,7 @@ update_firmware(int fd, uint8_t *payload, int32_t payload_size, uint8_t fwug)
 		errx(EX_OSERR, "unable to malloc %zd bytes", (size_t)max_xfer_size);
 
 	while (resid > 0) {
-		size = (resid >= (int32_t)max_xfer_size) ?
-		    max_xfer_size : resid;
+		size = (resid >= max_xfer_size) ?  max_xfer_size : resid;
 		memcpy(chunk, payload + off, size);
 
 		memset(&pt, 0, sizeof(pt));


More information about the dev-commits-src-all mailing list