Blame SOURCES/0006-Promote-_make_hd_dn-to-make_hd_dn-and-get-rid-of-the.patch

821f82
From bd8fc0ebe86da82468b40a4998c3000819e73afe Mon Sep 17 00:00:00 2001
821f82
From: Peter Jones <pjones@redhat.com>
821f82
Date: Tue, 12 Jun 2018 14:36:20 -0400
821f82
Subject: [PATCH 06/17] Promote _make_hd_dn() to make_hd_dn() and get rid of
821f82
 the wrapper.
821f82
821f82
The wrapper is just hiding what the code's doing, and all the other code
821f82
around where we use it does the same thing anyway.  This hopefully
821f82
convinces coverity we're not really dereferencing "buf" there unless
821f82
it's nonzero.
821f82
821f82
Signed-off-by: Peter Jones <pjones@redhat.com>
821f82
---
821f82
 src/creator.c  | 3 ++-
821f82
 src/disk.c     | 4 ++--
821f82
 src/dp-media.c | 2 ++
821f82
 src/disk.h     | 7 ++-----
821f82
 4 files changed, 8 insertions(+), 8 deletions(-)
821f82
821f82
diff --git a/src/creator.c b/src/creator.c
821f82
index 93f185fc0bc..76c1c1f7a99 100644
821f82
--- a/src/creator.c
821f82
+++ b/src/creator.c
821f82
@@ -281,7 +281,8 @@ efi_va_generate_file_device_path_from_esp(uint8_t *buf, ssize_t size,
821f82
 			goto err;
821f82
 		}
821f82
 
821f82
-		sz = make_hd_dn(buf, size, off, disk_fd, dev->part, options);
821f82
+		sz = make_hd_dn(buf+off, size?size-off:0,
821f82
+                                disk_fd, dev->part, options);
821f82
 		saved_errno = errno;
821f82
 		close(disk_fd);
821f82
 		errno = saved_errno;
821f82
diff --git a/src/disk.c b/src/disk.c
821f82
index deac512cf71..3efee03b804 100644
821f82
--- a/src/disk.c
821f82
+++ b/src/disk.c
821f82
@@ -257,8 +257,8 @@ is_partitioned(int fd)
821f82
 }
821f82
 
821f82
 ssize_t HIDDEN
821f82
-_make_hd_dn(uint8_t *buf, ssize_t size, int fd, int32_t partition,
821f82
-	    uint32_t options)
821f82
+make_hd_dn(uint8_t *buf, ssize_t size, int fd, int32_t partition,
821f82
+           uint32_t options)
821f82
 {
821f82
 	uint64_t part_start=0, part_size = 0;
821f82
 	uint8_t signature[16]="", format=0, signature_type=0;
821f82
diff --git a/src/dp-media.c b/src/dp-media.c
821f82
index 0a0993ec3f4..cec6b8bb58d 100644
821f82
--- a/src/dp-media.c
821f82
+++ b/src/dp-media.c
821f82
@@ -161,6 +161,7 @@ efidp_make_file(uint8_t *buf, ssize_t size, char *filepath)
821f82
 	ssize_t sz;
821f82
 	ssize_t len = utf8len(lf, -1) + 1;
821f82
 	ssize_t req = sizeof (*file) + len * sizeof (uint16_t);
821f82
+
821f82
 	sz = efidp_make_generic(buf, size, EFIDP_MEDIA_TYPE, EFIDP_MEDIA_FILE,
821f82
 				req);
821f82
 	if (size && sz == req) {
821f82
@@ -182,6 +183,7 @@ efidp_make_hd(uint8_t *buf, ssize_t size, uint32_t num, uint64_t part_start,
821f82
 	efidp_hd *hd = (efidp_hd *)buf;
821f82
 	ssize_t sz;
821f82
 	ssize_t req = sizeof (*hd);
821f82
+
821f82
 	sz = efidp_make_generic(buf, size, EFIDP_MEDIA_TYPE, EFIDP_MEDIA_HD,
821f82
 				req);
821f82
 	if (size && sz == req) {
821f82
diff --git a/src/disk.h b/src/disk.h
821f82
index c040cc92a91..f0fa7f9f42d 100644
821f82
--- a/src/disk.h
821f82
+++ b/src/disk.h
821f82
@@ -23,10 +23,7 @@
821f82
 
821f82
 extern bool HIDDEN is_partitioned(int fd);
821f82
 
821f82
-extern HIDDEN ssize_t _make_hd_dn(uint8_t *buf, ssize_t size, int fd,
821f82
-                                  int32_t partition, uint32_t options);
821f82
-#define make_hd_dn(buf, size, off, fd, partition, option) \
821f82
-	_make_hd_dn(((buf)+(off)), ((size)?((size)-(off)):0), (fd),\
821f82
-		    (partition), (options))
821f82
+extern HIDDEN ssize_t make_hd_dn(uint8_t *buf, ssize_t size, int fd,
821f82
+                                 int32_t partition, uint32_t options);
821f82
 
821f82
 #endif /* _EFIBOOT_DISK_H */
821f82
-- 
821f82
2.17.1
821f82