Re: __warn_references: drop redundant "warning: " prefix

2017-11-27 Thread Theo Buehler
On Sat, Nov 18, 2017 at 02:58:29AM +0100, Jeremie Courreges-Anglas wrote:
> On Sun, Nov 12 2017, Scott Cheloha  wrote:
> > Hi,
> >
> > GNU ld has prefixed the contents of .gnu.warning.SYMBOL sections
> > with "warning: " since 2003, so the messages themselves need not
> > contain the prefix anymore.
> >
> > If LLVM ld ever acknowledges .gnu.warning sections I imagine it
> > would emulate this behavior.
> 
> It would be good if lld gained support for .gnu.warning sections, those
> warnings put the light on code that should be improved; not only in the
> ports tree, as shown by the libcrypto warnings in base.
> 
> After a quick glance it seems that recent binutils versions have the
> same behavior, so it's reasonable to assume that lld would follow
> GNU ld(1) by prepending "warning:".  Especially if they don't want to
> get the same bug report as the gcc folks got:
> 
>   https://sourceware.org/ml/binutils/2003-08/msg8.html
> 
> > Thoughts?
> 
> The double "warning: " message looks just weird, removing it makes sense
> IMO.  ok jca@

I also support removing these. Any objections to putting this in?

> 
> > --
> > Scott Cheloha
> >
> > Index: lib/libc/arch/i386/string/strcat.S
> > ===
> > RCS file: /cvs/src/lib/libc/arch/i386/string/strcat.S,v
> > retrieving revision 1.9
> > diff -u -p -r1.9 strcat.S
> > --- lib/libc/arch/i386/string/strcat.S  31 Aug 2015 02:53:56 -  
> > 1.9
> > +++ lib/libc/arch/i386/string/strcat.S  12 Nov 2017 04:21:37 -
> > @@ -9,7 +9,7 @@
> >  #if defined(APIWARN)
> >  #APP
> > .section .gnu.warning.strcat
> > -   .ascii "warning: strcat() is almost always misused, please use 
> > strlcat()"
> > +   .ascii "strcat() is almost always misused, please use strlcat()"
> >  #NO_APP
> >  #endif
> >  
> > Index: lib/libc/arch/i386/string/strcpy.S
> > ===
> > RCS file: /cvs/src/lib/libc/arch/i386/string/strcpy.S,v
> > retrieving revision 1.9
> > diff -u -p -r1.9 strcpy.S
> > --- lib/libc/arch/i386/string/strcpy.S  31 Aug 2015 02:53:56 -  
> > 1.9
> > +++ lib/libc/arch/i386/string/strcpy.S  12 Nov 2017 04:21:37 -
> > @@ -9,7 +9,7 @@
> >  #if defined(APIWARN)
> >  #APP
> > .section .gnu.warning.strcpy
> > -   .ascii "warning: strcpy() is almost always misused, please use 
> > strlcpy()"
> > +   .ascii "strcpy() is almost always misused, please use strlcpy()"
> >  #NO_APP
> >  #endif
> >  
> > Index: lib/libc/compat-43/getwd.c
> > ===
> > RCS file: /cvs/src/lib/libc/compat-43/getwd.c,v
> > retrieving revision 1.11
> > diff -u -p -r1.11 getwd.c
> > --- lib/libc/compat-43/getwd.c  30 Sep 2013 12:02:30 -  1.11
> > +++ lib/libc/compat-43/getwd.c  12 Nov 2017 04:21:37 -
> > @@ -46,4 +46,4 @@ getwd(char *buf)
> >  }
> >  
> >  __warn_references(getwd,
> > -"warning: getwd() possibly used unsafely; consider using getcwd()");
> > +"getwd() possibly used unsafely; consider using getcwd()");
> > Index: lib/libc/stdio/mktemp.c
> > ===
> > RCS file: /cvs/src/lib/libc/stdio/mktemp.c,v
> > retrieving revision 1.38
> > diff -u -p -r1.38 mktemp.c
> > --- lib/libc/stdio/mktemp.c 13 Sep 2015 08:31:47 -  1.38
> > +++ lib/libc/stdio/mktemp.c 12 Nov 2017 04:21:37 -
> > @@ -119,7 +119,7 @@ _mktemp(char *path)
> >  }
> >  
> >  __warn_references(mktemp,
> > -"warning: mktemp() possibly used unsafely; consider using mkstemp()");
> > +"mktemp() possibly used unsafely; consider using mkstemp()");
> >  
> >  char *
> >  mktemp(char *path)
> > Index: lib/libc/stdio/sprintf.c
> > ===
> > RCS file: /cvs/src/lib/libc/stdio/sprintf.c,v
> > retrieving revision 1.18
> > diff -u -p -r1.18 sprintf.c
> > --- lib/libc/stdio/sprintf.c1 Oct 2015 02:32:07 -   1.18
> > +++ lib/libc/stdio/sprintf.c12 Nov 2017 04:21:37 -
> > @@ -39,7 +39,7 @@
> >  
> >  #if defined(APIWARN)
> >  __warn_references(sprintf,
> > -"warning: sprintf() is often misused, please use snprintf()");
> > +"sprintf() is often misused, please use snprintf()");
> >  #endif
> >  
> >  int
> > Index: lib/libc/stdio/tempnam.c
> > ===
> > RCS file: /cvs/src/lib/libc/stdio/tempnam.c,v
> > retrieving revision 1.19
> > diff -u -p -r1.19 tempnam.c
> > --- lib/libc/stdio/tempnam.c31 Aug 2015 02:53:57 -  1.19
> > +++ lib/libc/stdio/tempnam.c12 Nov 2017 04:21:37 -
> > @@ -37,7 +37,7 @@
> >  #include 
> >  
> >  __warn_references(tempnam,
> > -"warning: tempnam() possibly used unsafely; consider using mkstemp()");
> > +"tempnam() possibly used unsafely; consider using mkstemp()");
> >  
> >  char *
> >  

Re: __warn_references: drop redundant "warning: " prefix

2017-11-17 Thread Jeremie Courreges-Anglas
On Sun, Nov 12 2017, Scott Cheloha  wrote:
> Hi,
>
> GNU ld has prefixed the contents of .gnu.warning.SYMBOL sections
> with "warning: " since 2003, so the messages themselves need not
> contain the prefix anymore.
>
> If LLVM ld ever acknowledges .gnu.warning sections I imagine it
> would emulate this behavior.

It would be good if lld gained support for .gnu.warning sections, those
warnings put the light on code that should be improved; not only in the
ports tree, as shown by the libcrypto warnings in base.

After a quick glance it seems that recent binutils versions have the
same behavior, so it's reasonable to assume that lld would follow
GNU ld(1) by prepending "warning:".  Especially if they don't want to
get the same bug report as the gcc folks got:

  https://sourceware.org/ml/binutils/2003-08/msg8.html

> Thoughts?

The double "warning: " message looks just weird, removing it makes sense
IMO.  ok jca@

> --
> Scott Cheloha
>
> Index: lib/libc/arch/i386/string/strcat.S
> ===
> RCS file: /cvs/src/lib/libc/arch/i386/string/strcat.S,v
> retrieving revision 1.9
> diff -u -p -r1.9 strcat.S
> --- lib/libc/arch/i386/string/strcat.S31 Aug 2015 02:53:56 -  
> 1.9
> +++ lib/libc/arch/i386/string/strcat.S12 Nov 2017 04:21:37 -
> @@ -9,7 +9,7 @@
>  #if defined(APIWARN)
>  #APP
>   .section .gnu.warning.strcat
> - .ascii "warning: strcat() is almost always misused, please use 
> strlcat()"
> + .ascii "strcat() is almost always misused, please use strlcat()"
>  #NO_APP
>  #endif
>  
> Index: lib/libc/arch/i386/string/strcpy.S
> ===
> RCS file: /cvs/src/lib/libc/arch/i386/string/strcpy.S,v
> retrieving revision 1.9
> diff -u -p -r1.9 strcpy.S
> --- lib/libc/arch/i386/string/strcpy.S31 Aug 2015 02:53:56 -  
> 1.9
> +++ lib/libc/arch/i386/string/strcpy.S12 Nov 2017 04:21:37 -
> @@ -9,7 +9,7 @@
>  #if defined(APIWARN)
>  #APP
>   .section .gnu.warning.strcpy
> - .ascii "warning: strcpy() is almost always misused, please use 
> strlcpy()"
> + .ascii "strcpy() is almost always misused, please use strlcpy()"
>  #NO_APP
>  #endif
>  
> Index: lib/libc/compat-43/getwd.c
> ===
> RCS file: /cvs/src/lib/libc/compat-43/getwd.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 getwd.c
> --- lib/libc/compat-43/getwd.c30 Sep 2013 12:02:30 -  1.11
> +++ lib/libc/compat-43/getwd.c12 Nov 2017 04:21:37 -
> @@ -46,4 +46,4 @@ getwd(char *buf)
>  }
>  
>  __warn_references(getwd,
> -"warning: getwd() possibly used unsafely; consider using getcwd()");
> +"getwd() possibly used unsafely; consider using getcwd()");
> Index: lib/libc/stdio/mktemp.c
> ===
> RCS file: /cvs/src/lib/libc/stdio/mktemp.c,v
> retrieving revision 1.38
> diff -u -p -r1.38 mktemp.c
> --- lib/libc/stdio/mktemp.c   13 Sep 2015 08:31:47 -  1.38
> +++ lib/libc/stdio/mktemp.c   12 Nov 2017 04:21:37 -
> @@ -119,7 +119,7 @@ _mktemp(char *path)
>  }
>  
>  __warn_references(mktemp,
> -"warning: mktemp() possibly used unsafely; consider using mkstemp()");
> +"mktemp() possibly used unsafely; consider using mkstemp()");
>  
>  char *
>  mktemp(char *path)
> Index: lib/libc/stdio/sprintf.c
> ===
> RCS file: /cvs/src/lib/libc/stdio/sprintf.c,v
> retrieving revision 1.18
> diff -u -p -r1.18 sprintf.c
> --- lib/libc/stdio/sprintf.c  1 Oct 2015 02:32:07 -   1.18
> +++ lib/libc/stdio/sprintf.c  12 Nov 2017 04:21:37 -
> @@ -39,7 +39,7 @@
>  
>  #if defined(APIWARN)
>  __warn_references(sprintf,
> -"warning: sprintf() is often misused, please use snprintf()");
> +"sprintf() is often misused, please use snprintf()");
>  #endif
>  
>  int
> Index: lib/libc/stdio/tempnam.c
> ===
> RCS file: /cvs/src/lib/libc/stdio/tempnam.c,v
> retrieving revision 1.19
> diff -u -p -r1.19 tempnam.c
> --- lib/libc/stdio/tempnam.c  31 Aug 2015 02:53:57 -  1.19
> +++ lib/libc/stdio/tempnam.c  12 Nov 2017 04:21:37 -
> @@ -37,7 +37,7 @@
>  #include 
>  
>  __warn_references(tempnam,
> -"warning: tempnam() possibly used unsafely; consider using mkstemp()");
> +"tempnam() possibly used unsafely; consider using mkstemp()");
>  
>  char *
>  tempnam(const char *dir, const char *pfx)
> Index: lib/libc/stdio/tmpnam.c
> ===
> RCS file: /cvs/src/lib/libc/stdio/tmpnam.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 tmpnam.c
> --- lib/libc/stdio/tmpnam.c   31 Aug 2015 02:53:57 -  1.11
> +++ lib/libc/stdio/tmpnam.c   12 Nov 2017 04:21:37 -
> @@ -37,7 +37,7 @@
>  

__warn_references: drop redundant "warning: " prefix

2017-11-12 Thread Scott Cheloha
Hi,

GNU ld has prefixed the contents of .gnu.warning.SYMBOL sections
with "warning: " since 2003, so the messages themselves need not
contain the prefix anymore.

If LLVM ld ever acknowledges .gnu.warning sections I imagine it
would emulate this behavior.

Thoughts?

--
Scott Cheloha

Index: lib/libc/arch/i386/string/strcat.S
===
RCS file: /cvs/src/lib/libc/arch/i386/string/strcat.S,v
retrieving revision 1.9
diff -u -p -r1.9 strcat.S
--- lib/libc/arch/i386/string/strcat.S  31 Aug 2015 02:53:56 -  1.9
+++ lib/libc/arch/i386/string/strcat.S  12 Nov 2017 04:21:37 -
@@ -9,7 +9,7 @@
 #if defined(APIWARN)
 #APP
.section .gnu.warning.strcat
-   .ascii "warning: strcat() is almost always misused, please use 
strlcat()"
+   .ascii "strcat() is almost always misused, please use strlcat()"
 #NO_APP
 #endif
 
Index: lib/libc/arch/i386/string/strcpy.S
===
RCS file: /cvs/src/lib/libc/arch/i386/string/strcpy.S,v
retrieving revision 1.9
diff -u -p -r1.9 strcpy.S
--- lib/libc/arch/i386/string/strcpy.S  31 Aug 2015 02:53:56 -  1.9
+++ lib/libc/arch/i386/string/strcpy.S  12 Nov 2017 04:21:37 -
@@ -9,7 +9,7 @@
 #if defined(APIWARN)
 #APP
.section .gnu.warning.strcpy
-   .ascii "warning: strcpy() is almost always misused, please use 
strlcpy()"
+   .ascii "strcpy() is almost always misused, please use strlcpy()"
 #NO_APP
 #endif
 
Index: lib/libc/compat-43/getwd.c
===
RCS file: /cvs/src/lib/libc/compat-43/getwd.c,v
retrieving revision 1.11
diff -u -p -r1.11 getwd.c
--- lib/libc/compat-43/getwd.c  30 Sep 2013 12:02:30 -  1.11
+++ lib/libc/compat-43/getwd.c  12 Nov 2017 04:21:37 -
@@ -46,4 +46,4 @@ getwd(char *buf)
 }
 
 __warn_references(getwd,
-"warning: getwd() possibly used unsafely; consider using getcwd()");
+"getwd() possibly used unsafely; consider using getcwd()");
Index: lib/libc/stdio/mktemp.c
===
RCS file: /cvs/src/lib/libc/stdio/mktemp.c,v
retrieving revision 1.38
diff -u -p -r1.38 mktemp.c
--- lib/libc/stdio/mktemp.c 13 Sep 2015 08:31:47 -  1.38
+++ lib/libc/stdio/mktemp.c 12 Nov 2017 04:21:37 -
@@ -119,7 +119,7 @@ _mktemp(char *path)
 }
 
 __warn_references(mktemp,
-"warning: mktemp() possibly used unsafely; consider using mkstemp()");
+"mktemp() possibly used unsafely; consider using mkstemp()");
 
 char *
 mktemp(char *path)
Index: lib/libc/stdio/sprintf.c
===
RCS file: /cvs/src/lib/libc/stdio/sprintf.c,v
retrieving revision 1.18
diff -u -p -r1.18 sprintf.c
--- lib/libc/stdio/sprintf.c1 Oct 2015 02:32:07 -   1.18
+++ lib/libc/stdio/sprintf.c12 Nov 2017 04:21:37 -
@@ -39,7 +39,7 @@
 
 #if defined(APIWARN)
 __warn_references(sprintf,
-"warning: sprintf() is often misused, please use snprintf()");
+"sprintf() is often misused, please use snprintf()");
 #endif
 
 int
Index: lib/libc/stdio/tempnam.c
===
RCS file: /cvs/src/lib/libc/stdio/tempnam.c,v
retrieving revision 1.19
diff -u -p -r1.19 tempnam.c
--- lib/libc/stdio/tempnam.c31 Aug 2015 02:53:57 -  1.19
+++ lib/libc/stdio/tempnam.c12 Nov 2017 04:21:37 -
@@ -37,7 +37,7 @@
 #include 
 
 __warn_references(tempnam,
-"warning: tempnam() possibly used unsafely; consider using mkstemp()");
+"tempnam() possibly used unsafely; consider using mkstemp()");
 
 char *
 tempnam(const char *dir, const char *pfx)
Index: lib/libc/stdio/tmpnam.c
===
RCS file: /cvs/src/lib/libc/stdio/tmpnam.c,v
retrieving revision 1.11
diff -u -p -r1.11 tmpnam.c
--- lib/libc/stdio/tmpnam.c 31 Aug 2015 02:53:57 -  1.11
+++ lib/libc/stdio/tmpnam.c 12 Nov 2017 04:21:37 -
@@ -37,7 +37,7 @@
 #include 
 
 __warn_references(tmpnam,
-"warning: tmpnam() possibly used unsafely; consider using mkstemp()");
+"tmpnam() possibly used unsafely; consider using mkstemp()");
 
 char *
 tmpnam(char *s)
Index: lib/libc/stdio/vsprintf.c
===
RCS file: /cvs/src/lib/libc/stdio/vsprintf.c,v
retrieving revision 1.16
diff -u -p -r1.16 vsprintf.c
--- lib/libc/stdio/vsprintf.c   9 Nov 2009 00:18:28 -   1.16
+++ lib/libc/stdio/vsprintf.c   12 Nov 2017 04:21:37 -
@@ -38,7 +38,7 @@
 
 #if defined(APIWARN)
 __warn_references(vsprintf,
-"warning: vsprintf() is often misused, please use vsnprintf()");
+"vsprintf() is often misused, please use vsnprintf()");
 #endif
 
 int
Index: lib/libc/stdlib/rand.c
===
RCS file: /cvs/src/lib/libc/stdlib/rand.c,v
retrieving