All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Fabiano Rosas <farosas@suse.de>
Cc: qemu-devel@nongnu.org, Thomas Huth <thuth@redhat.com>
Subject: Re: [PATCH v2 6/7] migration: Fix arrays of pointers in JSON writer
Date: Thu, 9 Jan 2025 11:21:52 -0500	[thread overview]
Message-ID: <Z3_3oPAypaz2HOfW@x1n> (raw)
In-Reply-To: <87r05c2c9m.fsf@suse.de>

On Thu, Jan 09, 2025 at 01:16:37PM -0300, Fabiano Rosas wrote:
> > Btw, since the new code will process it correctly with non-array below,
> > IIUC here we can make it simple:
> >
> >   if 'index' in field:
> >       self.data[fname] = fdata
> >
> 
> Sorry, I don't understand what you mean here. I changed it now to:
> 
>     if fname not in self.data:
>         if 'index' in field:
>             self.data[fname] = [fdata]
>         else:
>             self.data[fname] = fdata
>     elif type(self.data[fname]) == list:
>         self.data[fname].append(fdata)
>     else:
>         tmp = self.data[fname]
>         self.data[fname] = [tmp, fdata]

I meant we could avoid checking "index" completely now with the new code
knowing how to expand, so IIUC it can be simplified to:

  if fname not in self.data:
      self.data[fname] = fdata
  elif type(self.data[fname]) == list:
      self.data[fname].append(fdata)
  else:
      tmp = self.data[fname]
      self.data[fname] = [tmp, fdata]

-- 
Peter Xu



  reply	other threads:[~2025-01-09 16:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 14:09 [PATCH v2 0/7] migration: Fix s390 regressions + migration script Fabiano Rosas
2025-01-09 14:09 ` [PATCH v2 1/7] migration: Add more error handling to analyze-migration.py Fabiano Rosas
2025-01-09 14:09 ` [PATCH v2 2/7] migration: Remove unused argument in vmsd_desc_field_end Fabiano Rosas
2025-01-09 14:09 ` [PATCH v2 3/7] migration: Fix parsing of s390 stream Fabiano Rosas
2025-01-09 14:09 ` [PATCH v2 4/7] migration: Rename vmstate_info_nullptr Fabiano Rosas
2025-01-09 14:22   ` Peter Xu
2025-01-09 15:53     ` Fabiano Rosas
2025-01-09 14:09 ` [PATCH v2 5/7] migration: Dump correct JSON format for nullptr replacement Fabiano Rosas
2025-01-09 14:09 ` [PATCH v2 6/7] migration: Fix arrays of pointers in JSON writer Fabiano Rosas
2025-01-09 14:34   ` Peter Xu
2025-01-09 16:16     ` Fabiano Rosas
2025-01-09 16:21       ` Peter Xu [this message]
2025-01-09 16:25         ` Fabiano Rosas
2025-01-09 14:09 ` [PATCH v2 7/7] s390x: Fix CSS migration Fabiano Rosas

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=Z3_3oPAypaz2HOfW@x1n \
    --to=peterx@redhat.com \
    --cc=farosas@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.