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

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