bug-gnulib
[Top][All Lists]
Advanced

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

Re: strchrnul speed


From: Eric Blake
Subject: Re: strchrnul speed
Date: Tue, 29 Apr 2008 06:35:00 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Bruno Haible on 4/28/2008 4:06 PM:
| Why should a developer who uses gnulib have to write valgrind
suppression files
| to work around ISO C99 violations in gnulib? We can at least provide a
| strchrnul.valgrind file, like the 'malloca' module already does.

Done, in the patch below; the patch is untested, since valgrind does not
run on cygwin, but the result is similar to malloca.valgrind and matches
the documentation found at
http://valgrind.org/docs/manual/manual-core.html#manual-core.suppress.

| Then this
| developer can use the option
|    --suppressions=$(srcdir)/strchrnul.valgrind
| in his Makefile. Several --suppressions options can be given;
gnulib-tool does
| not need to combine the various suppressions files.

Well, for now we are safe.  But 'man valgrind' states:
~ --suppressions=<filename>   [default:   $PREFIX/lib/valgrind/default.supp]
~              Specifies  an  extra  file  from  which  to  read
~              descriptions of errors to suppress. You may spec-
~              ify up to 10 additional suppression files.

I hate it when programs have arbitrary limits.

Also, it looks like the valgrind --partial-loads-ok option is supposed to
be a good heuristic for use cases such as what is in strchrnul and rawmemchr.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgXFfQACgkQ84KuGfSFAYCtOQCeJg1Sqguc2vo00m/Q9KNk1VgH
xSUAnAlGTDhVByNQRjK+MWCZG4Z9EXkC
=eFnM
-----END PGP SIGNATURE-----
>From f54ab4c77f02cdc8fc480d2bb0aa406eb8ff9039 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 29 Apr 2008 06:08:44 -0600
Subject: [PATCH] Silence valgrind on safe reads beyond potential array bounds.

* lib/rawmemchr.valgrind: New file.
* lib/strchrnul.valgrind: Likewise.
* modules/rawmemchr (Files): Distribute new file.
* modules/strchrnul (Files): Likewise.
Suggested by Bruno Haible.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog              |    9 +++++++++
 lib/rawmemchr.valgrind |   12 ++++++++++++
 lib/strchrnul.valgrind |   12 ++++++++++++
 modules/rawmemchr      |    1 +
 modules/strchrnul      |    1 +
 5 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100644 lib/rawmemchr.valgrind
 create mode 100644 lib/strchrnul.valgrind

diff --git a/ChangeLog b/ChangeLog
index ceaee07..ed3c210 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-04-29  Eric Blake  <address@hidden>
+
+       Silence valgrind on safe reads beyond potential array bounds.
+       * lib/rawmemchr.valgrind: New file.
+       * lib/strchrnul.valgrind: Likewise.
+       * modules/rawmemchr (Files): Distribute new file.
+       * modules/strchrnul (Files): Likewise.
+       Suggested by Bruno Haible.
+
 2008-04-29  Bruno Haible  <address@hidden>
 
        * lib/arpa_inet.in.h: Include system's <arpa/inet.h> if it exists.
diff --git a/lib/rawmemchr.valgrind b/lib/rawmemchr.valgrind
new file mode 100644
index 0000000..6363923
--- /dev/null
+++ b/lib/rawmemchr.valgrind
@@ -0,0 +1,12 @@
+# Suppress a valgrind message about use of uninitialized memory in rawmemchr().
+# This use is OK because it provides only a speedup.
+{
+    rawmemchr-value4
+    Memcheck:Value4
+    fun:rawmemchr
+}
+{
+    rawmemchr-value8
+    Memcheck:Value8
+    fun:rawmemchr
+}
diff --git a/lib/strchrnul.valgrind b/lib/strchrnul.valgrind
new file mode 100644
index 0000000..b14fa13
--- /dev/null
+++ b/lib/strchrnul.valgrind
@@ -0,0 +1,12 @@
+# Suppress a valgrind message about use of uninitialized memory in strchrnul().
+# This use is OK because it provides only a speedup.
+{
+    strchrnul-value4
+    Memcheck:Value4
+    fun:strchrnul
+}
+{
+    strchrnul-value8
+    Memcheck:Value8
+    fun:strchrnul
+}
diff --git a/modules/rawmemchr b/modules/rawmemchr
index bcbe7e8..d8fdbbb 100644
--- a/modules/rawmemchr
+++ b/modules/rawmemchr
@@ -3,6 +3,7 @@ rawmemchr() function: Find the first occurrence of C in S.
 
 Files:
 lib/rawmemchr.c
+lib/rawmemchr.valgrind
 m4/rawmemchr.m4
 
 Depends-on:
diff --git a/modules/strchrnul b/modules/strchrnul
index 2901768..2f75450 100644
--- a/modules/strchrnul
+++ b/modules/strchrnul
@@ -4,6 +4,7 @@ byte.
 
 Files:
 lib/strchrnul.c
+lib/strchrnul.valgrind
 m4/strchrnul.m4
 
 Depends-on:
-- 
1.5.5.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]