Re: [PATCH] disk-utils: fix libuuid usage in mkswap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 06, 2007 at 05:56:50PM +0200, Matthias Koenig wrote:
> Karel Zak <kzak@xxxxxxxxxx> writes:
> >  It would be nice to have a script that compares all HAVE_* from code
> >  to the config.h.in
> >
> >       $ grep -r HAVE_ *   
> >  
> >  ... and I see that cal.c uses HAVE_NCURSES, but we have
> >  HAVE_NCURSES_H only :-(
> 
> Something like this (first approach)?

 Yes! ;-)

> 	DEFINES=$(sed -n -e 's/.*\(HAVE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
>                          -e 's/.*\(ENABLE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
>                          $f | sort | uniq)

 I'm definitely not RE guru, bit it seems that:

    's/.*[ \t(]\+\(HAVE_[[:alnum:]]\+[^ \t);]*\).*/\1/p'

 doesn't return false positives like FOO_HAVE_BAR.

> Still, most of the results are false positives:
> 
> login.c: HAVE_UT_TV
> _HAVE_UT_TV defined in bits/utmp.h
> 
> shutdown.c: ENABLE_CAD
> false positive

 Fixed with the new RE.

> mkfs.cramfs.c: HAVE_MD5
> false positive, defined in source

 Fixed, use HAVE_ for something other for config.h stuff is
 dirty.

> mcookie.c: HAVE_GETTIMEOFDAY
> false positive, defined in source

 Fixed. We don't have care about non-linux code.

 #ifdef __linux__ is very funny in util-linux ;-)

> cal.c: HAVE_NCURSES
> Already been mentioned

 Fixed.

> getopt.c: HAVE_LIBINTL_H
> Refers to getopt/gnu/getopt.c
> gettext related? I am not really sure where this is supposed to come from.
> Anyway, the source file seems to be not used at all, gnu/getopt.c looks 
> like a fallback implementation for getopt, but there is no configure 
> check or anything in the build infrastructure which might trigger this.

 Fixed by git-rm.


 I added a tools/ directory and your script (with small changes), see:


>From 71be1ee4a1386c141272df32b1184857aa5c9070 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@xxxxxxxxxx>
Date: Fri, 15 Jun 2007 10:17:51 +0200
Subject: [PATCH] tools: add codecheck-config that checks for {HAVE,ENABLE}_ orphans

Signed-off-by: Matthias Koenig <mkoenig@xxxxxxx>
Signed-off-by: Karel Zak <kzak@xxxxxxxxxx>
---
 Makefile.am            |    3 ++-
 tools/codecheck-config |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletions(-)
 create mode 100755 tools/codecheck-config

diff --git a/Makefile.am b/Makefile.am
index 1b91651..e3d7be5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,8 @@ EXTRA_DIST = \
 		README.devel \
 		licenses/ \
 		example.files/ \
-		po/update-potfiles
+		po/update-potfiles \
+		tools
 
 
 distclean-local:
diff --git a/tools/codecheck-config b/tools/codecheck-config
new file mode 100755
index 0000000..ff38bac
--- /dev/null
+++ b/tools/codecheck-config
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+#
+# This script checks for HAVE_ and ENABLE_ macros which are
+# not included in config.h.in
+#
+# Copyright (C) 2007 Matthias Koenig <mkoenig@xxxxxxx>
+#
+
+srcdir=$1
+
+if [ ! "$srcdir" ]; then
+	srcdir=$PWD
+fi
+
+CONFIG="$srcdir/config.h.in"
+if [ ! -f "$CONFIG" ]; then
+	echo "config.h.in is needed"
+	exit 1
+fi
+
+SOURCES=$(find $srcdir -name "*.c")
+
+for f in $SOURCES; do
+	DEFINES=$(sed -n -e 's/.*[ \t(]\+\(HAVE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
+                         -e 's/.*[ \t(]\+\(ENABLE_[[:alnum:]]\+[^ \t);]*\).*/\1/p' \
+                         $f | sort -u)
+	[ -z "$DEFINES" ] && continue
+
+	for d in $DEFINES; do
+		case $d in
+		HAVE_CONFIG_H) continue;;
+		*) grep -q "$d\( \|\>\)" $CONFIG || echo $(echo $f | sed 's:'$srcdir/'::') ": $d"
+
+	           ;;
+		esac
+	done
+done
-- 
1.5.0.6


-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux