* [AArch64] Use snprintf instead sprintf
@ 2012-06-01 8:54 Sofiane Naci
2012-06-08 8:58 ` Marcus Shawcroft
0 siblings, 1 reply; 3+ messages in thread
From: Sofiane Naci @ 2012-06-01 8:54 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 699 bytes --]
Hi,
This patch replaces instances of sprintf with snprintf with sizeof(..) in
the AArch64 port.
It also fixes layout issues in the code it touches.
Thanks
Sofiane
-----
ChangeLog
2012-06-01 Sofiane Naci <sofiane.naci@arm.com>
[AArch64] Replace sprintf with snprintf.
* config/aarch64/aarch64.c
(aarch64_elf_asm_constructor): Replace sprintf with snprintf.
(aarch64_elf_asm_destructor): Likewise.
(aarch64_output_casesi): Likewise.
(aarch64_output_asm_insn): Likewise.
* config/aarch64/aarch64-builtins.c (init_aarch64_simd_builtins):
Likewise.
* config/aarch64/aarch64-simd.md (*aarch64_simd_mov<mode>): Replace
sprintf with snprintf, and fix code layout.
[-- Attachment #2: aarch64-snprintf.patch --]
[-- Type: application/octet-stream, Size: 3682 bytes --]
diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index 297ca18..186b589 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -1017,8 +1017,8 @@ init_aarch64_simd_builtins (void)
gcc_assert (ftype != NULL);
- sprintf (namebuf, "__builtin_aarch64_%s%s", d->name,
- modenames[j]);
+ snprintf (namebuf, sizeof (namebuf), "__builtin_aarch64_%s%s",
+ d->name, modenames[j]);
add_builtin_function (namebuf, ftype, fcode++, BUILT_IN_MD, NULL,
NULL_TREE);
diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md
index 85c8c2b..dc795a9 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -407,14 +407,14 @@
if (mvn == 0)
{
if (widthc != 'd')
- sprintf (templ,"movi\t%%0.%d%c, %%1, lsl %d ",(64/width),
- widthc, shift);
+ snprintf (templ, sizeof (templ), "movi\t%%0.%d%c, %%1, lsl %d ",
+ 64 / width, widthc, shift);
else
- sprintf (templ,"movi\t%%d0, %%1");
+ snprintf (templ, sizeof (templ), "movi\t%%d0, %%1");
}
else
- sprintf (templ,"mvni\t%%0.%d%c, %%1, lsl %d",(64/width),
- widthc, shift);
+ snprintf (templ, sizeof (templ), "mvni\t%%0.%d%c, %%1, lsl %d",
+ 64 / width, widthc, shift);
return templ;
}
default: gcc_unreachable ();
@@ -455,11 +455,11 @@
&mvn, &shift);
gcc_assert (is_valid != 0);
if (mvn == 0)
- sprintf (templ,"movi\t%%0.%d%c, %%1, lsl %d ", (128/width),
- widthc, shift);
+ snprintf (templ, sizeof (templ), "movi\t%%0.%d%c, %%1, lsl %d ",
+ 128 / width, widthc, shift);
else
- sprintf (templ,"mvni\t%%0.%d%c, %%1, lsl %d", (128/width),
- widthc, shift);
+ snprintf (templ, sizeof (templ), "mvni\t%%0.%d%c, %%1, lsl %d",
+ 128 / width, widthc, shift);
return templ;
}
default: gcc_unreachable ();
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 34d0475..933d7d6 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -3768,7 +3768,7 @@ aarch64_elf_asm_constructor (rtx symbol, int priority)
{
section *s;
char buf[18];
- sprintf (buf, ".init_array.%.5u", priority);
+ snprintf (buf, sizeof (buf), ".init_array.%.5u", priority);
s = get_section (buf, SECTION_WRITE, NULL);
switch_to_section (s);
assemble_align (POINTER_SIZE);
@@ -3787,7 +3787,7 @@ aarch64_elf_asm_destructor (rtx symbol, int priority)
{
section *s;
char buf[18];
- sprintf (buf, ".fini_array.%.5u", priority);
+ snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);
s = get_section (buf, SECTION_WRITE, NULL);
switch_to_section (s);
assemble_align (POINTER_SIZE);
@@ -3836,7 +3836,8 @@ aarch64_output_casesi (rtx *operands)
/* Need to implement table size reduction, by chaning the code below. */
output_asm_insn (patterns[index][0], operands);
ASM_GENERATE_INTERNAL_LABEL (label, "Lrtx", CODE_LABEL_NUMBER (operands[2]));
- sprintf (buf, "adr\t%%4, %s", targetm.strip_name_encoding (label));
+ snprintf (buf, sizeof (buf),
+ "adr\t%%4, %s", targetm.strip_name_encoding (label));
output_asm_insn (buf, operands);
output_asm_insn (patterns[index][1], operands);
output_asm_insn ("br\t%3", operands);
@@ -5891,7 +5892,7 @@ aarch64_output_asm_insn (emit_f emit, int label, rtx *operands,
char buffer[256];
va_start (ap, pattern);
- vsprintf (buffer, pattern, ap);
+ vsnprintf (buffer, sizeof (buffer), pattern, ap);
va_end (ap);
emit (label, buffer, operands);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [AArch64] Use snprintf instead sprintf
2012-06-01 8:54 [AArch64] Use snprintf instead sprintf Sofiane Naci
@ 2012-06-08 8:58 ` Marcus Shawcroft
2012-06-22 17:56 ` Tejas Belagod
0 siblings, 1 reply; 3+ messages in thread
From: Marcus Shawcroft @ 2012-06-08 8:58 UTC (permalink / raw)
To: Sofiane Naci; +Cc: gcc-patches
On 01/06/12 09:53, Sofiane Naci wrote:
> Hi,
>
> This patch replaces instances of sprintf with snprintf with sizeof(..) in
> the AArch64 port.
> It also fixes layout issues in the code it touches.
>
> Thanks
> Sofiane
>
> -----
>
> ChangeLog
>
> 2012-06-01 Sofiane Naci<sofiane.naci@arm.com>
>
> [AArch64] Replace sprintf with snprintf.
>
> * config/aarch64/aarch64.c
> (aarch64_elf_asm_constructor): Replace sprintf with snprintf.
> (aarch64_elf_asm_destructor): Likewise.
> (aarch64_output_casesi): Likewise.
> (aarch64_output_asm_insn): Likewise.
> * config/aarch64/aarch64-builtins.c (init_aarch64_simd_builtins):
> Likewise.
> * config/aarch64/aarch64-simd.md (*aarch64_simd_mov<mode>): Replace
> sprintf with snprintf, and fix code layout.
OK for aarch64 branch.
/Marcus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [AArch64] Use snprintf instead sprintf
2012-06-08 8:58 ` Marcus Shawcroft
@ 2012-06-22 17:56 ` Tejas Belagod
0 siblings, 0 replies; 3+ messages in thread
From: Tejas Belagod @ 2012-06-22 17:56 UTC (permalink / raw)
To: gcc-patches; +Cc: Marcus Shawcroft, Sofiane Naci
Marcus Shawcroft wrote:
> On 01/06/12 09:53, Sofiane Naci wrote:
>> Hi,
>>
>> This patch replaces instances of sprintf with snprintf with sizeof(..) in
>> the AArch64 port.
>> It also fixes layout issues in the code it touches.
>>
>> Thanks
>> Sofiane
>>
>> -----
>>
>> ChangeLog
>>
>> 2012-06-01 Sofiane Naci<sofiane.naci@arm.com>
>>
>> [AArch64] Replace sprintf with snprintf.
>>
>> * config/aarch64/aarch64.c
>> (aarch64_elf_asm_constructor): Replace sprintf with snprintf.
>> (aarch64_elf_asm_destructor): Likewise.
>> (aarch64_output_casesi): Likewise.
>> (aarch64_output_asm_insn): Likewise.
>> * config/aarch64/aarch64-builtins.c (init_aarch64_simd_builtins):
>> Likewise.
>> * config/aarch64/aarch64-simd.md (*aarch64_simd_mov<mode>): Replace
>> sprintf with snprintf, and fix code layout.
>
> OK for aarch64 branch.
> /Marcus
>
>
I've checked this in on aarch64-branch for Sofiane.
Tejas.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-22 17:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-01 8:54 [AArch64] Use snprintf instead sprintf Sofiane Naci
2012-06-08 8:58 ` Marcus Shawcroft
2012-06-22 17:56 ` Tejas Belagod
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).