Skip to contentSkip to conversation

xfsprogs: enable sparse checking

PATCH In review Eric Sandeen 3 participants 8 messages Oct 23, 2014 – Oct 27, 2014 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfsprogs: enable sparse checking

Enable "make C=1" or "make C=2" to do sparse checking. Blatantly ripped off from djwong's patch in e2fsprogs to do the same.

Note, this requires unreleased sparse after v0.5, which enables the CHAR_BIT definition; otherwise it chokes.

---

Makefile +14 -0
index f56aebd..bd0f9ee 100644
@@ -15,6 +15,20 @@ else
   Q = @
 endif
 
+CHECK=sparse
+CHECK_OPTS=-Wsparse-all -Wno-transparent-union -Wno-return-void -Wno-undef \
+	-Wno-non-pointer-null -D__linux__
+ifeq ("$(C)", "2")
+  CHECK_CMD=$(CHECK) $(CHECK_OPTS) -Wbitwise -D__CHECK_ENDIAN__ 
+else
+  ifeq ("$(C)", "1")
+    CHECK_CMD=$(CHECK) $(CHECK_OPTS)
+   else
+    CHECK_CMD=@true
+  endif
+endif
+export CHECK_CMD
+
 MAKEOPTS = --no-print-directory Q=$(Q)
 
 TOPDIR = .
include/buildrules +2 -0
index 399635e..feae376 100644
@@ -41,10 +41,12 @@ $(LTLIBRARY) : $(SUBDIRS) $(LTOBJECTS)
 %.lo: %.c
 	@echo "    [CC]     $@"
 	$(Q)$(LTCOMPILE) -c $<
+	$(Q)$(CHECK_CMD) $(CFLAGS) $<
 else
 %.o: %.c
 	@echo "    [CC]     $@"
 	$(Q)$(CC) $(CFLAGS) -c $<
+	$(Q)$(CHECK_CMD) $(CFLAGS) $<
 
 endif
 

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 6 lines · Eric Sandeen

Enable "make C=1" or "make C=2" to do sparse checking. Blatantly ripped off from djwong's patch in e2fsprogs to do the same.

Note, this requires unreleased sparse after v0.5, which enables the CHAR_BIT definition; otherwise it chokes.

I'm pretty sure I used to be able to do sparse checks on xfsprogs using

CC=cgcc make

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Eric Sandeen

Enable "make C=1" or "make C=2" to do sparse checking. Blatantly ripped off from djwong's patch in e2fsprogs to do the same.

Note, this requires unreleased sparse after v0.5, which enables the CHAR_BIT definition; otherwise it chokes.

I'm pretty sure I used to be able to do sparse checks on xfsprogs using

CC=cgcc make

Hm, so you can.

Ok, so maybe this is dumb, or is it convenient (to work like it does in the kernel tree?)

Thanks,
-Eric

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 4 lines · Eric Sandeen

Hm, so you can.

Ok, so maybe this is dumb, or is it convenient (to work like it does in the kernel tree?)

The cgcc way seems easier for userspace, but I don't really have a strong opinion. It's not like your patch prevents me from using CC=cgcc

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw
Quoted 5 lines · Eric Sandeen
Quoted 1 line · Christoph Hellwig

strong opinion. It's not like your patch prevents me from using CC=cgcc

To get endian checking with your method, you'd need to edit the Makefile to add the -D define, right?

That's a kernel special, I just did a test run using CC=cgcc and I get endianess warnings:

rdwr.c:190:21: warning: incorrect type in assignment (different base types)
rdwr.c:190:21: expected restricted __le32 [usertype] h_crc
rdwr.c:190:21: got restricted __be32 [usertype] <noident>

log_misc.c:621:59: warning: cast to restricted __be64 log_misc.c:621:59: warning: cast to restricted __be64 log_misc.c:621:59: warning: cast to restricted __be64 log_misc.c:621:59: warning: cast to restricted __be64 log_misc.c:621:59: warning: cast to restricted __be64 log_misc.c:621:59: warning: cast to restricted __be64 log_misc.c:621:59: warning: cast to restricted __be64 log_misc.c:621:59: warning: cast to restricted __be64 log_misc.c:621:59: warning: cast to restricted __be64 log_misc.c:621:59: warning: cast to restricted __be64

There's also tons of noise that should be easily upgradeable, but let me check latests xfsprogs first..

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#6 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Eric Sandeen
Quoted 1 line · Christoph Hellwig

strong opinion. It's not like your patch prevents me from using CC=cgcc

To get endian checking with your method, you'd need to edit the Makefile to add the -D define, right?

Quoted 6 lines

That's a kernel special, I just did a test run using CC=cgcc and I get endianess warnings:

rdwr.c:190:21: warning: incorrect type in assignment (different base types)
rdwr.c:190:21: expected restricted __le32 [usertype] h_crc
rdwr.c:190:21: got restricted __be32 [usertype] <noident>

Oh, without an extra define? Hrm. Ok I guess I need to read up on what enables it.

I did send a couple patches to fix some of these. Sorry, didn't do it in a series:

[PATCH] xfsprogs: fix endian mishap in xfs_dialloc_ag() [PATCH] xfsprogs: fix harmless sparse endian nit

-Eric

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#7 lore raw
In reply to Eric Sandeen
Quoted 6 lines · Eric Sandeen

Enable "make C=1" or "make C=2" to do sparse checking. Blatantly ripped off from djwong's patch in e2fsprogs to do the same.

Note, this requires unreleased sparse after v0.5, which enables the CHAR_BIT definition; otherwise it chokes.

Ok, NAK to this one I guess, hch has sufficiently pointed out that I don't quite know what I'm doing here ;)

-Eric

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs