* [PATCH] kernel/sysctl: Resolve missing-field-initializers warnings
@ 2014-10-14 11:41 Jeff Kirsher
2014-10-19 0:39 ` Eric W. Biederman
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Kirsher @ 2014-10-14 11:41 UTC (permalink / raw)
To: akpm, mingo; +Cc: Mark Rustad, linux-kernel, Jeff Kirsher
From: Mark Rustad <mark.d.rustad@intel.com>
Resolve missing-field-initializers warnings in W=2 builds by
using designated initialization.
Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
kernel/sysctl.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 4aada6d..5623845 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -257,7 +257,7 @@ static struct ctl_table sysctl_base_table[] = {
.mode = 0555,
.child = dev_table,
},
- { }
+ { .procname = NULL }
};
#ifdef CONFIG_SCHED_DEBUG
@@ -1103,7 +1103,7 @@ static struct ctl_table kern_table[] = {
.proc_handler = proc_dointvec,
},
#endif
- { }
+ { .procname = NULL }
};
static struct ctl_table vm_table[] = {
@@ -1485,12 +1485,12 @@ static struct ctl_table vm_table[] = {
.mode = 0644,
.proc_handler = proc_doulongvec_minmax,
},
- { }
+ { .procname = NULL }
};
#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
static struct ctl_table binfmt_misc_table[] = {
- { }
+ { .procname = NULL }
};
#endif
@@ -1658,7 +1658,7 @@ static struct ctl_table fs_table[] = {
.proc_handler = &pipe_proc_fn,
.extra1 = &pipe_min_size,
},
- { }
+ { .procname = NULL }
};
static struct ctl_table debug_table[] = {
@@ -1682,11 +1682,11 @@ static struct ctl_table debug_table[] = {
.extra2 = &one,
},
#endif
- { }
+ { .procname = NULL }
};
static struct ctl_table dev_table[] = {
- { }
+ { .procname = NULL }
};
int __init sysctl_init(void)
--
1.9.3
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] kernel/sysctl: Resolve missing-field-initializers warnings
2014-10-14 11:41 [PATCH] kernel/sysctl: Resolve missing-field-initializers warnings Jeff Kirsher
@ 2014-10-19 0:39 ` Eric W. Biederman
2014-10-21 19:07 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Eric W. Biederman @ 2014-10-19 0:39 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: akpm, mingo, Mark Rustad, linux-kernel
Jeff Kirsher <jeffrey.t.kirsher@intel.com> writes:
> From: Mark Rustad <mark.d.rustad@intel.com>
>
> Resolve missing-field-initializers warnings in W=2 builds by
> using designated initialization.
ick. No.
That gcc warning makes no sense. In this case heeding it makes the code
significantly uglier and significantly more confusing.
Eric
> Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
> kernel/sysctl.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 4aada6d..5623845 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -257,7 +257,7 @@ static struct ctl_table sysctl_base_table[] = {
> .mode = 0555,
> .child = dev_table,
> },
> - { }
> + { .procname = NULL }
> };
>
> #ifdef CONFIG_SCHED_DEBUG
> @@ -1103,7 +1103,7 @@ static struct ctl_table kern_table[] = {
> .proc_handler = proc_dointvec,
> },
> #endif
> - { }
> + { .procname = NULL }
> };
>
> static struct ctl_table vm_table[] = {
> @@ -1485,12 +1485,12 @@ static struct ctl_table vm_table[] = {
> .mode = 0644,
> .proc_handler = proc_doulongvec_minmax,
> },
> - { }
> + { .procname = NULL }
> };
>
> #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
> static struct ctl_table binfmt_misc_table[] = {
> - { }
> + { .procname = NULL }
> };
> #endif
>
> @@ -1658,7 +1658,7 @@ static struct ctl_table fs_table[] = {
> .proc_handler = &pipe_proc_fn,
> .extra1 = &pipe_min_size,
> },
> - { }
> + { .procname = NULL }
> };
>
> static struct ctl_table debug_table[] = {
> @@ -1682,11 +1682,11 @@ static struct ctl_table debug_table[] = {
> .extra2 = &one,
> },
> #endif
> - { }
> + { .procname = NULL }
> };
>
> static struct ctl_table dev_table[] = {
> - { }
> + { .procname = NULL }
> };
>
> int __init sysctl_init(void)
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] kernel/sysctl: Resolve missing-field-initializers warnings
2014-10-19 0:39 ` Eric W. Biederman
@ 2014-10-21 19:07 ` Andrew Morton
2014-10-21 20:34 ` Rustad, Mark D
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2014-10-21 19:07 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: Jeff Kirsher, mingo, Mark Rustad, linux-kernel
On Sat, 18 Oct 2014 17:39:10 -0700 ebiederm@xmission.com (Eric W. Biederman) wrote:
> Jeff Kirsher <jeffrey.t.kirsher@intel.com> writes:
>
> > From: Mark Rustad <mark.d.rustad@intel.com>
> >
> > Resolve missing-field-initializers warnings in W=2 builds by
> > using designated initialization.
>
> ick. No.
>
> That gcc warning makes no sense. In this case heeding it makes the code
> significantly uglier and significantly more confusing.
>
Yeah, it's not pretty.
> > --- a/kernel/sysctl.c
> > +++ b/kernel/sysctl.c
> > @@ -257,7 +257,7 @@ static struct ctl_table sysctl_base_table[] = {
> > .mode = 0555,
> > .child = dev_table,
> > },
> > - { }
> > + { .procname = NULL }
> > };
We use { } to mean "all zero" in 12 squillion places. Do they all warn
or is there something special about this site?
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] kernel/sysctl: Resolve missing-field-initializers warnings
2014-10-21 19:07 ` Andrew Morton
@ 2014-10-21 20:34 ` Rustad, Mark D
0 siblings, 0 replies; 4+ messages in thread
From: Rustad, Mark D @ 2014-10-21 20:34 UTC (permalink / raw)
To: Andrew Morton; +Cc: Eric W. Biederman, Kirsher, Jeffrey T, mingo, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2558 bytes --]
On Oct 21, 2014, at 12:07 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Sat, 18 Oct 2014 17:39:10 -0700 ebiederm@xmission.com (Eric W. Biederman) wrote:
>
>> Jeff Kirsher <jeffrey.t.kirsher@intel.com> writes:
>>
>>> From: Mark Rustad <mark.d.rustad@intel.com>
>>>
>>> Resolve missing-field-initializers warnings in W=2 builds by
>>> using designated initialization.
>>
>> ick. No.
>>
>> That gcc warning makes no sense. In this case heeding it makes the code
>> significantly uglier and significantly more confusing.
>>
>
> Yeah, it's not pretty.
>
>>> --- a/kernel/sysctl.c
>>> +++ b/kernel/sysctl.c
>>> @@ -257,7 +257,7 @@ static struct ctl_table sysctl_base_table[] = {
>>> .mode = 0555,
>>> .child = dev_table,
>>> },
>>> - { }
>>> + { .procname = NULL }
>>> };
>
> We use { } to mean "all zero" in 12 squillion places. Do they all warn
> or is there something special about this site?
Well, about 6 squillion of them are { }, a GCC extension, and the other 6 squillion are { 0 }. Both forms generate the warning. There is nothing special about this site. I just was resolving warnings in order to find some that had some significance. A flood of 125,000 warnings is too awful to look at. I got it down to around 1,500 and did find a few hazards and sent patches to address them, which have been accepted in one form or another.
I had sent patches to add diagnostic control macros to allow a warning to be turned off for a range of code. I would have liked to use them to provide something like a ZERO_ENTRY macro that would have looked something like this:
#define ZERO_ENTRY DIAG_PUSH DIAG_IGNORE(missing-field-initializers) { 0 } DIAG_POP
which would have provided a standard way to get a zero entry that would have avoided the warnings. Borislav was quite opposed to the notion of diagnostic control macros. I rather like the notion as long as their use is tightly controlled.
I'm sure that we both feel that there should be a form that the compiler does not generate this warning for as a preferred solution. The designated initialization is at best a 3rd-best solution, though naming the field used to identify the end of the table is not a bad thing either.
I do like enabling lots of additional warnings to find problems in code, but when it results in such a flood of messages it is not a very useful approach, hence my tendency to want to address them somehow, so that meaningful ones can be noticed.
--
Mark Rustad, Networking Division, Intel Corporation
[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 841 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-22 1:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-14 11:41 [PATCH] kernel/sysctl: Resolve missing-field-initializers warnings Jeff Kirsher
2014-10-19 0:39 ` Eric W. Biederman
2014-10-21 19:07 ` Andrew Morton
2014-10-21 20:34 ` Rustad, Mark D
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®