Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/gpl3 Introduce a syslog format that accepts %m. Sto...
details: https://anonhg.NetBSD.org/src/rev/5d33932e97c8
branches: trunk
changeset: 341019:5d33932e97c8
user: christos <christos%NetBSD.org@localhost>
date: Wed Oct 14 16:05:14 2015 +0000
description:
Introduce a syslog format that accepts %m. Stop accepting %m in printf
like formats. Support for this is detected via the __syslog_attribute__
macro.
diffstat:
external/gpl3/gcc.old/dist/gcc/c-family/c-format.c | 19 +++++++++++++++++--
external/gpl3/gcc.old/dist/gcc/c-family/c-format.h | 4 +++-
external/gpl3/gcc.old/dist/gcc/config/netbsd.h | 1 +
external/gpl3/gcc/dist/gcc/c-family/c-format.c | 19 +++++++++++++++++--
external/gpl3/gcc/dist/gcc/c-family/c-format.h | 4 +++-
external/gpl3/gcc/dist/gcc/config/netbsd.h | 1 +
6 files changed, 42 insertions(+), 6 deletions(-)
diffs (156 lines):
diff -r 251fe30d5832 -r 5d33932e97c8 external/gpl3/gcc.old/dist/gcc/c-family/c-format.c
--- a/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c Wed Oct 14 16:02:03 2015 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c Wed Oct 14 16:05:14 2015 +0000
@@ -860,14 +860,20 @@
},
{ "gnu_strftime", NULL, time_char_table, "_-0^#", "EO",
strftime_flag_specs, strftime_flag_pairs,
- FMT_FLAG_FANCY_PERCENT_OK, 'w', 0, 0, 0, 0, 0,
+ FMT_FLAG_FANCY_PERCENT_OK|FMT_FLAG_M_OK, 'w', 0, 0, 0, 0, 0,
NULL, NULL
},
{ "gnu_strfmon", strfmon_length_specs, monetary_char_table, "=^+(!-", NULL,
strfmon_flag_specs, strfmon_flag_pairs,
FMT_FLAG_ARG_CONVERT, 'w', '#', 'p', 0, 'L', 0,
NULL, NULL
- }
+ },
+ { "gnu_syslog", printf_length_specs, print_char_table, " +#0-'I", NULL,
+ printf_flag_specs, printf_flag_pairs,
+ FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK|FMT_FLAG_M_OK,
+ 'w', 0, 'p', 0, 'L', 0,
+ &integer_type_node, &integer_type_node
+ },
};
/* This layer of indirection allows GCC to reassign format_types with
@@ -1983,6 +1989,14 @@
warning (OPT_Wformat_, "conversion lacks type at end of format");
continue;
}
+
+ if (format_char == 'm' && !(fki->flags & FMT_FLAG_M_OK))
+ {
+ warning (OPT_Wformat_,
+ "%%m is only allowed in syslog(3) like functions");
+ continue;
+ }
+
format_chars++;
fci = fki->conversion_specs;
while (fci->format_chars != 0
@@ -2854,6 +2868,7 @@
static const target_ovr_attr gnu_target_overrides_format_attributes[] =
{
{ "gnu_printf", "printf" },
+ { "gnu_syslog", "syslog" },
{ "gnu_scanf", "scanf" },
{ "gnu_strftime", "strftime" },
{ "gnu_strfmon", "strfmon" },
diff -r 251fe30d5832 -r 5d33932e97c8 external/gpl3/gcc.old/dist/gcc/c-family/c-format.h
--- a/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h Wed Oct 14 16:02:03 2015 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h Wed Oct 14 16:05:14 2015 +0000
@@ -75,11 +75,13 @@
FMT_FLAG_DOLLAR_GAP_POINTER_OK = 128,
/* The format arg is an opaque object that will be parsed by an external
facility. */
- FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL = 256
+ FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL = 256,
/* Not included here: details of whether width or precision may occur
(controlled by width_char and precision_char); details of whether
'*' can be used for these (width_type and precision_type); details
of whether length modifiers can occur (length_char_specs). */
+ FMT_FLAG_M_OK = 512
+ /* %m is only allowed in syslog */
};
/* Structure describing a length modifier supported in format checking, and
diff -r 251fe30d5832 -r 5d33932e97c8 external/gpl3/gcc.old/dist/gcc/config/netbsd.h
--- a/external/gpl3/gcc.old/dist/gcc/config/netbsd.h Wed Oct 14 16:02:03 2015 +0000
+++ b/external/gpl3/gcc.old/dist/gcc/config/netbsd.h Wed Oct 14 16:05:14 2015 +0000
@@ -23,6 +23,7 @@
{ \
builtin_define ("__NetBSD__"); \
builtin_define ("__unix__"); \
+ builtin_define ("__syslog_attribute__"); \
builtin_assert ("system=bsd"); \
builtin_assert ("system=unix"); \
builtin_assert ("system=NetBSD"); \
diff -r 251fe30d5832 -r 5d33932e97c8 external/gpl3/gcc/dist/gcc/c-family/c-format.c
--- a/external/gpl3/gcc/dist/gcc/c-family/c-format.c Wed Oct 14 16:02:03 2015 +0000
+++ b/external/gpl3/gcc/dist/gcc/c-family/c-format.c Wed Oct 14 16:05:14 2015 +0000
@@ -860,14 +860,20 @@
},
{ "gnu_strftime", NULL, time_char_table, "_-0^#", "EO",
strftime_flag_specs, strftime_flag_pairs,
- FMT_FLAG_FANCY_PERCENT_OK, 'w', 0, 0, 0, 0, 0,
+ FMT_FLAG_FANCY_PERCENT_OK|FMT_FLAG_M_OK, 'w', 0, 0, 0, 0, 0,
NULL, NULL
},
{ "gnu_strfmon", strfmon_length_specs, monetary_char_table, "=^+(!-", NULL,
strfmon_flag_specs, strfmon_flag_pairs,
FMT_FLAG_ARG_CONVERT, 'w', '#', 'p', 0, 'L', 0,
NULL, NULL
- }
+ },
+ { "gnu_syslog", printf_length_specs, print_char_table, " +#0-'I", NULL,
+ printf_flag_specs, printf_flag_pairs,
+ FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK|FMT_FLAG_M_OK,
+ 'w', 0, 'p', 0, 'L', 0,
+ &integer_type_node, &integer_type_node
+ },
};
/* This layer of indirection allows GCC to reassign format_types with
@@ -1983,6 +1989,14 @@
warning (OPT_Wformat_, "conversion lacks type at end of format");
continue;
}
+
+ if (format_char == 'm' && !(fki->flags & FMT_FLAG_M_OK))
+ {
+ warning (OPT_Wformat_,
+ "%%m is only allowed in syslog(3) like functions");
+ continue;
+ }
+
format_chars++;
fci = fki->conversion_specs;
while (fci->format_chars != 0
@@ -2854,6 +2868,7 @@
static const target_ovr_attr gnu_target_overrides_format_attributes[] =
{
{ "gnu_printf", "printf" },
+ { "gnu_syslog", "syslog" },
{ "gnu_scanf", "scanf" },
{ "gnu_strftime", "strftime" },
{ "gnu_strfmon", "strfmon" },
diff -r 251fe30d5832 -r 5d33932e97c8 external/gpl3/gcc/dist/gcc/c-family/c-format.h
--- a/external/gpl3/gcc/dist/gcc/c-family/c-format.h Wed Oct 14 16:02:03 2015 +0000
+++ b/external/gpl3/gcc/dist/gcc/c-family/c-format.h Wed Oct 14 16:05:14 2015 +0000
@@ -75,11 +75,13 @@
FMT_FLAG_DOLLAR_GAP_POINTER_OK = 128,
/* The format arg is an opaque object that will be parsed by an external
facility. */
- FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL = 256
+ FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL = 256,
/* Not included here: details of whether width or precision may occur
(controlled by width_char and precision_char); details of whether
'*' can be used for these (width_type and precision_type); details
of whether length modifiers can occur (length_char_specs). */
+ FMT_FLAG_M_OK = 512
+ /* %m is only allowed in syslog */
};
/* Structure describing a length modifier supported in format checking, and
diff -r 251fe30d5832 -r 5d33932e97c8 external/gpl3/gcc/dist/gcc/config/netbsd.h
--- a/external/gpl3/gcc/dist/gcc/config/netbsd.h Wed Oct 14 16:02:03 2015 +0000
+++ b/external/gpl3/gcc/dist/gcc/config/netbsd.h Wed Oct 14 16:05:14 2015 +0000
@@ -23,6 +23,7 @@
{ \
builtin_define ("__NetBSD__"); \
builtin_define ("__unix__"); \
+ builtin_define ("__syslog_attribute__"); \
builtin_assert ("system=bsd"); \
builtin_assert ("system=unix"); \
builtin_assert ("system=NetBSD"); \
Home |
Main Index |
Thread Index |
Old Index