Skip to contentSkip to conversation

Fix build issues

PATCH Superseded Guoqing Jiang 1 participant 3 messages May 18, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Fix build issues

Hi Jes,

Hopefully this version addresses your comments.

V2 Changes:
1. copy the whole license from util.c to uuid.c
2. check the return value of read correctly

Thanks,
Guoqing

Guoqing Jiang (2):
uuid.c: split uuid stuffs from util.c
restripe: fix ignoring return value of ‘read’

 Makefile   |   6 +--
 restripe.c |  10 ++++-
 util.c     |  87 -----------------------------------------
 uuid.c     | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 124 insertions(+), 91 deletions(-)
 create mode 100644 uuid.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/2 uuid.c: split uuid stuffs from util.c

Currently, 'make raid6check' is build broken since commit b06815989 ("mdadm: load default sysfs attributes after assemblation").

/usr/bin/ld: sysfs.o: in function `sysfsline':
sysfs.c:(.text+0x2707): undefined reference to parse_uuid' /usr/bin/ld: sysfs.c:(.text+0x271a): undefined reference to uuid_zero' /usr/bin/ld: sysfs.c:(.text+0x2721): undefined reference to `uuid_zero'

Apparently, the compile of mdadm or raid6check are coupled with uuid functions inside util.c. However, we can't just add util.o to CHECK_OBJS which raid6check is needed, because it caused other worse problems.

So, let's introduce a uuid.c file which is indenpended file to fix the problem, all the contents are splitted from util.c.

---
 Makefile |   6 +--
 util.c   |  87 ------------------------------------------
 uuid.c   | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 115 insertions(+), 90 deletions(-)
 create mode 100644 uuid.c
Makefile +3 -3
index a33319a..d13030c 100644
@@ -139,7 +139,7 @@ else
 	ECHO=:
 endif
 
-OBJS =  mdadm.o config.o policy.o mdstat.o  ReadMe.o util.o maps.o lib.o \
+OBJS =  mdadm.o config.o policy.o mdstat.o  ReadMe.o uuid.o util.o maps.o lib.o \
 	Manage.o Assemble.o Build.o \
 	Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \
 	Incremental.o Dump.o \
@@ -148,13 +148,13 @@ OBJS =  mdadm.o config.o policy.o mdstat.o  ReadMe.o util.o maps.o lib.o \
 	restripe.o sysfs.o sha1.o mapfile.o crc32.o sg_io.o msg.o xmalloc.o \
 	platform-intel.o probe_roms.o crc32c.o
 
-CHECK_OBJS = restripe.o sysfs.o maps.o lib.o xmalloc.o dlink.o
+CHECK_OBJS = restripe.o uuid.o sysfs.o maps.o lib.o xmalloc.o dlink.o
 
 SRCS =  $(patsubst %.o,%.c,$(OBJS))
 
 INCL = mdadm.h part.h bitmap.h
 
-MON_OBJS = mdmon.o monitor.o managemon.o util.o maps.o mdstat.o sysfs.o \
+MON_OBJS = mdmon.o monitor.o managemon.o uuid.o util.o maps.o mdstat.o sysfs.o \
 	policy.o lib.o \
 	Kill.o sg_io.o dlink.o ReadMe.o super-intel.o \
 	super-mbr.o super-gpt.o \
util.c +0 -87

99 lines not on this page · raw message

uuid.c new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/2 restripe: fix ignoring return value of ‘read’

In reply to Guoqing Jiang

Got below error when run "make everything".

restripe.c: In function ‘test_stripes’:
restripe.c:870:4: error: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Werror=unused-result]

    read(source[i], stripes[i], chunk_size);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix it by check the return value of ‘read’, and free memory in the failure case.

---
 restripe.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
restripe.c +9 -1
index 31b07e8..48c6506 100644
@@ -867,7 +867,15 @@ int test_stripes(int *source, unsigned long long *offsets,
 
 		for (i = 0 ; i < raid_disks ; i++) {
 			lseek64(source[i], offsets[i]+start, 0);
-			read(source[i], stripes[i], chunk_size);
+			if (read(source[i], stripes[i], chunk_size) !=
+			    chunk_size) {
+				free(q);
+				free(p);
+				free(blocks);
+				free(stripes);
+				free(stripe_buf);
+				return -1;
+			}
 		}
 		for (i = 0 ; i < data_disks ; i++) {
 			int disk = geo_map(i, start/chunk_size, raid_disks,
Signature · 1 line
2.17.1