mbox series

[PATCH-for-8.1,0/5] bulk: Do not declare function prototypes using 'extern' keyword

Message ID 20230320134219.22489-1-philmd@linaro.org
Headers show
Series bulk: Do not declare function prototypes using 'extern' keyword | expand

Message

Philippe Mathieu-Daudé March 20, 2023, 1:42 p.m. UTC
- Remove the 'extern' keyword on function prototypes declared
  in header.
- Replace __attribute__((noreturn)) -> G_NORETURN
- Trivial cleanups to keep the previous commits generic.

TODO: Add a rule in scripts/checkpatch.pl :)

Based-on: <20230320131426.16348-1-philmd@linaro.org>

Philippe Mathieu-Daudé (5):
  qemu/osdep.h: Do not declare function prototypes using extern keyword
  block/dmg: Remove duplicated prototype declarations
  qemu/uri: Use QueryParams type definition
  bulk: Do not declare function prototypes using extern keyword
  bulk: Replace __attribute__((noreturn)) -> G_NORETURN

 block/dmg.h                    |  8 +++----
 bsd-user/bsd-file.h            |  6 ++---
 crypto/hmacpriv.h              | 13 +++++------
 hw/xen/xen_pt.h                |  8 +++----
 include/crypto/secret_common.h | 14 +++++-------
 include/exec/page-vary.h       |  4 ++--
 include/hw/misc/aspeed_scu.h   |  2 +-
 include/hw/nvram/npcm7xx_otp.h |  4 ++--
 include/hw/qdev-core.h         |  4 ++--
 include/qemu/crc-ccitt.h       |  4 ++--
 include/qemu/osdep.h           |  4 ++--
 include/qemu/rcu.h             | 14 ++++++------
 include/qemu/sys_membarrier.h  |  4 ++--
 include/qemu/uri.h             |  6 ++---
 include/sysemu/accel-blocker.h | 14 ++++++------
 include/sysemu/os-win32.h      |  4 ++--
 include/user/safe-syscall.h    |  4 ++--
 target/i386/sev.h              |  6 ++---
 target/mips/cpu.h              |  4 ++--
 tcg/tcg-internal.h             |  4 ++--
 tests/tcg/minilib/minilib.h    |  2 +-
 include/exec/memory_ldst.h.inc | 42 +++++++++++++++++-----------------
 block/dmg.c                    |  6 -----
 tests/migration/stress.c       |  2 +-
 roms/seabios                   |  2 +-
 25 files changed, 86 insertions(+), 99 deletions(-)

Comments

Daniel P. Berrangé March 20, 2023, 1:48 p.m. UTC | #1
On Mon, Mar 20, 2023 at 02:42:18PM +0100, Philippe Mathieu-Daudé wrote:
> By default, C function prototypes declared in headers are visible,
> so there is no need to declare them as 'extern' functions.
> Remove this redundancy in a single bulk commit; do not modify:
> 
>   - meson.build (used to check function availability at runtime)
>   - pc-bios
>   - libdecnumber
>   - *.c
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  block/dmg.h                    |  8 +++----
>  bsd-user/bsd-file.h            |  6 ++---
>  crypto/hmacpriv.h              | 13 +++++------
>  hw/xen/xen_pt.h                |  8 +++----
>  include/crypto/secret_common.h | 14 +++++-------
>  include/exec/page-vary.h       |  4 ++--
>  include/hw/misc/aspeed_scu.h   |  2 +-
>  include/hw/nvram/npcm7xx_otp.h |  4 ++--
>  include/hw/qdev-core.h         |  4 ++--
>  include/qemu/crc-ccitt.h       |  4 ++--
>  include/qemu/osdep.h           |  2 +-
>  include/qemu/rcu.h             | 14 ++++++------
>  include/qemu/sys_membarrier.h  |  4 ++--
>  include/qemu/uri.h             |  6 ++---
>  include/sysemu/accel-blocker.h | 14 ++++++------
>  include/sysemu/os-win32.h      |  4 ++--
>  include/user/safe-syscall.h    |  4 ++--
>  target/i386/sev.h              |  6 ++---
>  target/mips/cpu.h              |  4 ++--
>  tcg/tcg-internal.h             |  4 ++--
>  tests/tcg/minilib/minilib.h    |  2 +-
>  include/exec/memory_ldst.h.inc | 42 +++++++++++++++++-----------------
>  roms/seabios                   |  2 +-

Accidental submodule commit.,

>  23 files changed, 84 insertions(+), 91 deletions(-)
> 
> diff --git a/block/dmg.h b/block/dmg.h
> index e488601b62..ed209b5dec 100644
> --- a/block/dmg.h
> +++ b/block/dmg.h
> @@ -51,10 +51,10 @@ typedef struct BDRVDMGState {
>      z_stream zstream;
>  } BDRVDMGState;
>  
> -extern int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in,
> -                                 char *next_out, unsigned int avail_out);
> +int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in,
> +                          char *next_out, unsigned int avail_out);
>  
> -extern int (*dmg_uncompress_lzfse)(char *next_in, unsigned int avail_in,
> -                                   char *next_out, unsigned int avail_out);
> +int (*dmg_uncompress_lzfse)(char *next_in, unsigned int avail_in,
> +                            char *next_out, unsigned int avail_out);

These are variable declarations, so with this change you'll get multiple
copies of the variable if this header is included from multiple source
files. IOW, the 'extern' usage is correct.

> diff --git a/roms/seabios b/roms/seabios
> index ea1b7a0733..3208b098f5 160000
> --- a/roms/seabios
> +++ b/roms/seabios
> @@ -1 +1 @@
> -Subproject commit ea1b7a0733906b8425d948ae94fba63c32b1d425
> +Subproject commit 3208b098f51a9ef96d0dfa71d5ec3a3eaec88f0a

Nope !

With regards,
Daniel
Philippe Mathieu-Daudé March 20, 2023, 2:23 p.m. UTC | #2
On 20/3/23 14:48, Daniel P. Berrangé wrote:
> On Mon, Mar 20, 2023 at 02:42:18PM +0100, Philippe Mathieu-Daudé wrote:
>> By default, C function prototypes declared in headers are visible,
>> so there is no need to declare them as 'extern' functions.
>> Remove this redundancy in a single bulk commit; do not modify:
>>
>>    - meson.build (used to check function availability at runtime)
>>    - pc-bios
>>    - libdecnumber
>>    - *.c
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   block/dmg.h                    |  8 +++----
>>   bsd-user/bsd-file.h            |  6 ++---
>>   crypto/hmacpriv.h              | 13 +++++------
>>   hw/xen/xen_pt.h                |  8 +++----
>>   include/crypto/secret_common.h | 14 +++++-------
>>   include/exec/page-vary.h       |  4 ++--
>>   include/hw/misc/aspeed_scu.h   |  2 +-
>>   include/hw/nvram/npcm7xx_otp.h |  4 ++--
>>   include/hw/qdev-core.h         |  4 ++--
>>   include/qemu/crc-ccitt.h       |  4 ++--
>>   include/qemu/osdep.h           |  2 +-
>>   include/qemu/rcu.h             | 14 ++++++------
>>   include/qemu/sys_membarrier.h  |  4 ++--
>>   include/qemu/uri.h             |  6 ++---
>>   include/sysemu/accel-blocker.h | 14 ++++++------
>>   include/sysemu/os-win32.h      |  4 ++--
>>   include/user/safe-syscall.h    |  4 ++--
>>   target/i386/sev.h              |  6 ++---
>>   target/mips/cpu.h              |  4 ++--
>>   tcg/tcg-internal.h             |  4 ++--
>>   tests/tcg/minilib/minilib.h    |  2 +-
>>   include/exec/memory_ldst.h.inc | 42 +++++++++++++++++-----------------
>>   roms/seabios                   |  2 +-
> 
> Accidental submodule commit.,
> 
>>   23 files changed, 84 insertions(+), 91 deletions(-)
>>
>> diff --git a/block/dmg.h b/block/dmg.h
>> index e488601b62..ed209b5dec 100644
>> --- a/block/dmg.h
>> +++ b/block/dmg.h
>> @@ -51,10 +51,10 @@ typedef struct BDRVDMGState {
>>       z_stream zstream;
>>   } BDRVDMGState;
>>   
>> -extern int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in,
>> -                                 char *next_out, unsigned int avail_out);
>> +int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in,
>> +                          char *next_out, unsigned int avail_out);
>>   
>> -extern int (*dmg_uncompress_lzfse)(char *next_in, unsigned int avail_in,
>> -                                   char *next_out, unsigned int avail_out);
>> +int (*dmg_uncompress_lzfse)(char *next_in, unsigned int avail_in,
>> +                            char *next_out, unsigned int avail_out);
> 
> These are variable declarations, so with this change you'll get multiple
> copies of the variable if this header is included from multiple source
> files. IOW, the 'extern' usage is correct.

Doh indeed, good catch, thanks.

>> diff --git a/roms/seabios b/roms/seabios
>> index ea1b7a0733..3208b098f5 160000
>> --- a/roms/seabios
>> +++ b/roms/seabios
>> @@ -1 +1 @@
>> -Subproject commit ea1b7a0733906b8425d948ae94fba63c32b1d425
>> +Subproject commit 3208b098f51a9ef96d0dfa71d5ec3a3eaec88f0a
> 
> Nope !

Oops...