diff mbox series

[1/4] dump: Set dump info function pointers to NULL

Message ID 20231107142048.22422-2-frankja@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series dump: Arch info function pointer addition and cleanup | expand

Commit Message

Janosch Frank Nov. 7, 2023, 2:20 p.m. UTC
Better to not rely on the struct zeroing since NULL is not necessarily
0.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 dump/dump.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Marc-André Lureau Nov. 8, 2023, 8:03 a.m. UTC | #1
Hi

On Tue, Nov 7, 2023 at 6:22 PM Janosch Frank <frankja@linux.ibm.com> wrote:
>
> Better to not rely on the struct zeroing since NULL is not necessarily
> 0.
>
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  dump/dump.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/dump/dump.c b/dump/dump.c
> index d355ada62e..1d38274925 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -1706,6 +1706,9 @@ static void dump_state_prepare(DumpState *s)
>  {
>      /* zero the struct, setting status to active */
>      *s = (DumpState) { .status = DUMP_STATUS_ACTIVE };
> +    s->dump_info.arch_sections_add_fn = NULL;
> +    s->dump_info.arch_sections_write_hdr_fn = NULL;
> +    s->dump_info.arch_sections_write_fn = NULL;
>  }

I think we would be in trouble if NULL is not 0. Do you have a better argument?
Janosch Frank Nov. 8, 2023, 8:58 a.m. UTC | #2
On 11/8/23 09:03, Marc-André Lureau wrote:
> Hi
> 
> On Tue, Nov 7, 2023 at 6:22 PM Janosch Frank <frankja@linux.ibm.com> wrote:
>>
>> Better to not rely on the struct zeroing since NULL is not necessarily
>> 0.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>   dump/dump.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/dump/dump.c b/dump/dump.c
>> index d355ada62e..1d38274925 100644
>> --- a/dump/dump.c
>> +++ b/dump/dump.c
>> @@ -1706,6 +1706,9 @@ static void dump_state_prepare(DumpState *s)
>>   {
>>       /* zero the struct, setting status to active */
>>       *s = (DumpState) { .status = DUMP_STATUS_ACTIVE };
>> +    s->dump_info.arch_sections_add_fn = NULL;
>> +    s->dump_info.arch_sections_write_hdr_fn = NULL;
>> +    s->dump_info.arch_sections_write_fn = NULL;
>>   }
> 
> I think we would be in trouble if NULL is not 0. Do you have a better argument?
> 

I'm one of those people who likes to distinguish between pointers and 
non-pointers but I have no problem dropping this.


OT: On s390 0x0 is a valid address but the kernel maps & handles it in a 
way that it will result in a null pointer if read/written to.
diff mbox series

Patch

diff --git a/dump/dump.c b/dump/dump.c
index d355ada62e..1d38274925 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -1706,6 +1706,9 @@  static void dump_state_prepare(DumpState *s)
 {
     /* zero the struct, setting status to active */
     *s = (DumpState) { .status = DUMP_STATUS_ACTIVE };
+    s->dump_info.arch_sections_add_fn = NULL;
+    s->dump_info.arch_sections_write_hdr_fn = NULL;
+    s->dump_info.arch_sections_write_fn = NULL;
 }
 
 bool qemu_system_dump_in_progress(void)