On 23.01.17 18:48, Jakub Jelinek wrote:
On Mon, Jan 23, 2017 at 06:42:15PM +0100, Andreas Tobler wrote:
Something like below?

If ok, I can commit, right?

Thanks,

Andreas

2017-01-23  Andreas Tobler  <andre...@gcc.gnu.org>

        * config/aarch64/aarch64.c (aarch64_elf_asm_constructor): Increase
        size of buf.
        (aarch64_elf_asm_destructor): Likewise.
--- config/aarch64/aarch64.c    (revision 244819)
+++ config/aarch64/aarch64.c    (working copy)
@@ -5787,7 +5787,11 @@
   else
     {
       section *s;
-      char buf[18];
+      /* The size of the buf must be big enough to hold the string and the
+         full integer size of priority. Otherwise we will get a warning
+         about format-truncation.
+      */

Please put the */ on the same line as about format-truncation, like:
         about format-truncation.  */
After . there should be 2 spaces rather than one.
Also, the comment doesn't tell the truth, the buffer doesn't have to be that
big, because we know priority is bounded, just the compiler doesn't know
that.  So perhaps:
      /* While priority is known to be in range [0, 65535], so 18 bytes
         would be enough, the compiler might not know that.  To avoid
         -Wformat-truncation false positive, use a larger size.  */
      char buf[23];
or so?


Danke.

Andreas

2017-01-23  Andreas Tobler  <andre...@gcc.gnu.org>

        * config/aarch64/aarch64.c (aarch64_elf_asm_constructor): Increase
        size of buf.
        (aarch64_elf_asm_destructor): Likewise.

Index: config/aarch64/aarch64.c
===================================================================
--- config/aarch64/aarch64.c    (revision 244819)
+++ config/aarch64/aarch64.c    (working copy)
@@ -5787,7 +5787,10 @@
   else
     {
       section *s;
-      char buf[18];
+      /* While priority is known to be in range [0, 65535], so 18 bytes
+         would be enough, the compiler might not know that.  To avoid
+         -Wformat-truncation false positive, use a larger size.  */
+      char buf[23];
       snprintf (buf, sizeof (buf), ".init_array.%.5u", priority);
       s = get_section (buf, SECTION_WRITE, NULL);
       switch_to_section (s);
@@ -5804,7 +5807,10 @@
   else
     {
       section *s;
-      char buf[18];
+      /* While priority is known to be in range [0, 65535], so 18 bytes
+         would be enough, the compiler might not know that.  To avoid
+         -Wformat-truncation false positive, use a larger size.  */
+      char buf[23];
       snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);
       s = get_section (buf, SECTION_WRITE, NULL);
       switch_to_section (s);

Reply via email to