]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add syntax check rule to look for non-reentrant POSIX apis
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 20 Jan 2009 20:19:55 +0000 (20:19 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 20 Jan 2009 20:19:55 +0000 (20:19 +0000)
ChangeLog
Makefile.am
Makefile.cfg
Makefile.maint
Makefile.nonreentrant [new file with mode: 0644]

index e7fc60d21f297fef1e62d18c2eb6a61d761b9129..1a82a57a5195f68229071f6d6ab261ce5d4dd12b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Jan 20 19:49:53 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
+
+       * .x-sc_prohibit_nonreentrant: Blacklist some places where
+       use of non-threadsafe APIs are not neccessary to check
+       * Makefile.am, Makefile.maint, Makefile.nonreentrant: Add
+       check for non-reentrant safe API calls
+       * Makefile.cfg: Temporarily disable non-reentrant check
+
 Tue Jan 20 20:28:07 +0100 2009 Jim Meyering <meyering@redhat.com>
 
        don't ignore write failure
index 758ad50ffc509988e0999aea3dec6f0fd66fb725..d4e42f11686b0043ed5b782e8eacdbb9d1d786ff 100644 (file)
@@ -17,6 +17,8 @@ EXTRA_DIST = \
   .x-sc_require_config_h_first \
   .x-sc_prohibit_strcmp \
   .x-sc_require_config_h \
+  .x-sc_prohibit_nonreentrant \
+  Makefile.nonreentrant \
   autogen.sh
 
 man_MANS = virsh.1
index 1043d89bd38047fc3aee8af7e2c0ffa782551cb4..8964319ede00b529e55cb4601380da8805a96afe 100644 (file)
@@ -40,6 +40,7 @@ local-checks-to-skip =                        \
   sc_prohibit_jm_in_m4                 \
   sc_prohibit_quote_without_use                \
   sc_prohibit_quotearg_without_use     \
+  sc_prohibit_nonreentrant             \
   sc_root_tests                                \
   sc_space_tab                         \
   sc_sun_os_names                      \
index cfbdf56fd2cc722bca4a2acd60cc4a2fd75a46e0..0a8b6e917120d5175b240dbcae57ed6e3674311d 100644 (file)
@@ -13,6 +13,8 @@ VC_LIST = $(srcdir)/build-aux/vc-list-files
 VC_LIST_EXCEPT = \
   $(VC_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi
 
+include Makefile.nonreentrant
+
 # Prevent programs like 'sort' from considering distinct strings to be equal.
 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
 export LC_ALL = C
@@ -111,6 +113,15 @@ sc_prohibit_asprintf:
        @grep -nE '\<[a]sprintf\>' $$($(VC_LIST_EXCEPT)) && \
          { echo '$(ME): use virAsprintf, not a'sprintf 1>&2; exit 1; } || :
 
+sc_prohibit_nonreentrant:
+       @fail=0 ; \
+       for i in $(NON_REENTRANT) ; \
+       do \
+          grep -nE "\<$$i\>[:space:]*\(" $$($(VC_LIST_EXCEPT)) && \
+            fail=1 && echo "$(ME): use $${i}_r, not $${i}" || : ; \
+       done ; \
+       exit $$fail
+
 # Using EXIT_SUCCESS as the first argument to error is misleading,
 # since when that parameter is 0, error does not exit.  Use `0' instead.
 sc_error_exit_success:
diff --git a/Makefile.nonreentrant b/Makefile.nonreentrant
new file mode 100644 (file)
index 0000000..b567f31
--- /dev/null
@@ -0,0 +1,85 @@
+
+#
+# Generated by running the following on Fedora 9:
+#
+#  nm -D --defined-only /lib/libc.so.6  \
+#      | grep '_r$' \
+#      | awk '{print $3}' \
+#      | grep -v __ \
+#      | grep -v qsort \ # Red herring since we don't need to pass extra args to qsort comparator
+#      | grep -v readdir \ # This is safe as long as each DIR * instance is only used by one thread
+#      | sort \
+#      | uniq \
+#      | sed -e 's/_r//'
+#
+
+NON_REENTRANT =
+NON_REENTRANT += asctime
+NON_REENTRANT += ctime
+NON_REENTRANT += drand48
+NON_REENTRANT += ecvt
+NON_REENTRANT += erand48
+NON_REENTRANT += ether_aton
+NON_REENTRANT += ether_ntoa
+NON_REENTRANT += fcvt
+NON_REENTRANT += fgetgrent
+NON_REENTRANT += fgetpwent
+NON_REENTRANT += fgetspent
+NON_REENTRANT += getaliasbyname
+NON_REENTRANT += getaliasent
+NON_REENTRANT += getdate
+NON_REENTRANT += getgrent
+NON_REENTRANT += getgrgid
+NON_REENTRANT += getgrnam
+NON_REENTRANT += gethostbyaddr
+NON_REENTRANT += gethostbyname2
+NON_REENTRANT += gethostbyname
+NON_REENTRANT += gethostent
+NON_REENTRANT += getlogin
+NON_REENTRANT += getmntent
+NON_REENTRANT += getnetbyaddr
+NON_REENTRANT += getnetbyname
+NON_REENTRANT += getnetent
+NON_REENTRANT += getnetgrent
+NON_REENTRANT += getprotobyname
+NON_REENTRANT += getprotobynumber
+NON_REENTRANT += getprotoent
+NON_REENTRANT += getpwent
+NON_REENTRANT += getpwnam
+NON_REENTRANT += getpwuid
+NON_REENTRANT += getrpcbyname
+NON_REENTRANT += getrpcbynumber
+NON_REENTRANT += getrpcent
+NON_REENTRANT += getservbyname
+NON_REENTRANT += getservbyport
+NON_REENTRANT += getservent
+NON_REENTRANT += getspent
+NON_REENTRANT += getspnam
+NON_REENTRANT += getutent
+NON_REENTRANT += getutid
+NON_REENTRANT += getutline
+NON_REENTRANT += gmtime
+NON_REENTRANT += hcreate
+NON_REENTRANT += hdestroy
+NON_REENTRANT += hsearch
+NON_REENTRANT += initstate
+NON_REENTRANT += jrand48
+NON_REENTRANT += lcong48
+NON_REENTRANT += localtime
+NON_REENTRANT += lrand48
+NON_REENTRANT += mrand48
+NON_REENTRANT += nrand48
+NON_REENTRANT += ptsname
+NON_REENTRANT += qecvt
+NON_REENTRANT += qfcvt
+NON_REENTRANT += random
+NON_REENTRANT += rand
+NON_REENTRANT += seed48
+NON_REENTRANT += setstate
+NON_REENTRANT += sgetspent
+NON_REENTRANT += srand48
+NON_REENTRANT += srandom
+NON_REENTRANT += strerror
+NON_REENTRANT += strtok
+NON_REENTRANT += tmpnam
+NON_REENTRANT += ttyname