public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Darshana Padmadas <darshanapadmadas@gmail.com>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de,
	mingo@redhat.com, hpa@zytor.com, x86@kernel.org,
	josh@joshtriplett.org, Borislav Petkov <bp@alien8.de>
Subject: Re: [PATCH 01/16] arch: x86: boot: Make function static and add function prototype
Date: Wed, 4 Mar 2015 19:50:44 +0100	[thread overview]
Message-ID: <20150304185043.GA5110@gmail.com> (raw)
In-Reply-To: <40cee6529458e725e48fddac329d9a9da0de67c3.1425473428.git.darshanapadmadas@gmail.com>


* Darshana Padmadas <darshanapadmadas@gmail.com> wrote:

> compressed/eboot.c defines an internal function
> setup_graphics(struct boot_params *boot_params). No
> other file refers to this function with the same
> parameters so make this function static.
> 
> This eliminates the following warning:
> 
> arch/x86/boot/compressed/eboot.c:1004:6: warning: no previous prototype for ‘setup_graphics’ [-Wmissing-prototypes]
> 
> Also make_boot_params is declared only in this file and is used
> in some assembly. So add a prototype for this function.
> 
> This eliminates the following warning:
> 
> arch/x86/boot/compressed/eboot.c:1042:21: warning: no previous prototype for ‘make_boot_params’ [-Wmissing-prototypes]
> 
> Signed-off-by: Darshana Padmadas <darshanapadmadas@gmail.com>
> ---
>  arch/x86/boot/compressed/eboot.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
> index 92b9a5f..cb4ebab 100644
> --- a/arch/x86/boot/compressed/eboot.c
> +++ b/arch/x86/boot/compressed/eboot.c
> @@ -1001,7 +1001,7 @@ free_handle:
>  	return status;
>  }
>  
> -void setup_graphics(struct boot_params *boot_params)
> +static void setup_graphics(struct boot_params *boot_params)

This category of change is good: making needlessly global functions 
static is absolutely useful even if the kernel doesn't use the 
-Wmissing-prototypes warning, because this allows the compiler to 
potentially inline the function and thus reduce the size of the 
kernel. (even if it's not inlined, it's a small reduction in kernel 
image size.)

>  {
>  	efi_guid_t graphics_proto = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
>  	struct screen_info *si;
> @@ -1039,6 +1039,9 @@ void setup_graphics(struct boot_params *boot_params)
>   * The caller is responsible for filling out ->code32_start in the
>   * returned boot_params.
>   */
> +
> +struct boot_params *make_boot_params(struct efi_config *c);
> +
>  struct boot_params *make_boot_params(struct efi_config *c)

This category of change is not so useful in that form: look at the 
duplicated line in the .c file, it looks weird and not very useful at 
first glance already.

The way this is typically solved in user-space projects that use -Wall 
-Werror (such as tools/perf/) is to stick the external prototypes into 
a proper header file.

If a function is global because it's only interfacing with assembly 
code then put that into a comment before the prototype lines as well, 
in the header file. In this case the extra prototypes are also useful: 
they keep people modifying those functions informed and careful, as 
changing the function parameters signature could break assembly code 
without creating any obvious build time errors or warnings.

Thanks,

	Ingo

  reply	other threads:[~2015-03-04 18:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 13:32 [PATCH 00/16] Eliminate GCC -Wmissing-prototype warnings Darshana Padmadas
2015-03-04 13:32 ` [PATCH 01/16] arch: x86: boot: Make function static and add function prototype Darshana Padmadas
2015-03-04 18:50   ` Ingo Molnar [this message]
2015-03-04 13:32 ` [PATCH 02/16] arch: x86: boot: Add prototype for decompress_kernel Darshana Padmadas
2015-03-04 13:32 ` [PATCH 03/16] arch: x86: boot: Include header string.h for function prototypes Darshana Padmadas
2015-03-04 13:32 ` [PATCH 04/16] arch: x86: ia32: Add prototype for compat_ni_syscall Darshana Padmadas
2015-03-04 13:32 ` [PATCH 05/16] arch: x86: kernel: Make internal functions static in cpu/intel_cacheinfo.c Darshana Padmadas
2015-03-04 18:46   ` Borislav Petkov
2015-03-04 18:54     ` Ingo Molnar
2015-03-04 13:32 ` [PATCH 06/16] arch: x86: kernel: cpu: Mark function mce_chrdev_write static Darshana Padmadas
2015-03-04 13:32 ` [PATCH 07/16] arch: x86: kernel: Mark internal function EVT_TO_HPET_DEV static Darshana Padmadas
2015-03-04 13:32 ` [PATCH 08/16] arch: x86: kernel: Mark internal functions static in kvm.c Darshana Padmadas
2015-03-04 13:32 ` [PATCH 09/16] arch: x86: kernel: Include <asm/switch_to.h> for function prototype Darshana Padmadas
2015-03-04 13:32 ` [PATCH 10/16] arch: x86: kernel: Add prototype for function sys32_x32_rt_sigreturn Darshana Padmadas
2015-03-04 13:32 ` [PATCH 11/16] arch: x86: kernel: Add prototype for smp_reboot_interrupt Darshana Padmadas
2015-03-04 13:32 ` [PATCH 12/16] arch: x86: kernel: Add prototype for fixup_bad_iret in traps.c Darshana Padmadas
2015-03-04 13:32 ` [PATCH 13/16] arch: x86: xen: Add prototype for xen_start_kernel in enlighten.c Darshana Padmadas
2015-03-04 13:32 ` [PATCH 14/16] arch: x86: xen: Mark internal function xen_flush_tlb_all static Darshana Padmadas
2015-03-04 13:32 ` [PATCH 15/16] arch: x86: xen: Add prototypes for functions defined in mmu.c Darshana Padmadas
2015-03-04 13:32 ` [PATCH 16/16] arch: x86: xen: Mark internal functions static in setup.c Darshana Padmadas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150304185043.GA5110@gmail.com \
    --to=mingo@kernel.org \
    --cc=bp@alien8.de \
    --cc=darshanapadmadas@gmail.com \
    --cc=hpa@zytor.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox