qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org, "David Hildenbrand" <david@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Richard Henderson" <rth@twiddle.net>,
	qemu-s390x@nongnu.org, "Halil Pasic" <pasic@linux.ibm.com>,
	"Anthony Perard" <anthony.perard@citrix.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	qemu-ppc@nongnu.org, xen-devel@lists.xenproject.org
Subject: Re: [Qemu-devel] [PATCH 2/3] machine: Eliminate unnecessary stringify() usage
Date: Tue, 8 Jan 2019 11:08:23 +1100	[thread overview]
Message-ID: <20190108000823.GH13339@umbus.fritz.box> (raw)
In-Reply-To: <20190107193020.21744-3-ehabkost@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 15854 bytes --]

On Mon, Jan 07, 2019 at 05:30:19PM -0200, Eduardo Habkost wrote:
> stringify() is useful when we need to use macros in compat_props
> (like when we set virtio-baloon-pci.class=PCI_CLASS_MEMORY_RAM at
> pc_i440fx_1_0_machine_options()), but it is pointless when we are
> already providing a number literal.
> 
> Replace stringify() with string literals when appropriate.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/core/machine.c |  8 ++--
>  hw/i386/pc.c      | 94 +++++++++++++++++++++++------------------------
>  hw/i386/pc_piix.c | 30 +++++++--------
>  hw/ppc/spapr.c    |  2 +-
>  4 files changed, 67 insertions(+), 67 deletions(-)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index f8563efb86..4b4d6c23de 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -135,11 +135,11 @@ GlobalProperty hw_compat_2_8[] = {
>      {
>          .driver   = "fw_cfg_mem",
>          .property = "x-file-slots",
> -        .value    = stringify(0x10),
> +        .value    = "0x10",
>      },{
>          .driver   = "fw_cfg_io",
>          .property = "x-file-slots",
> -        .value    = stringify(0x10),
> +        .value    = "0x10",
>      },{
>          .driver   = "pflash_cfi01",
>          .property = "old-multiple-chip-handling",
> @@ -337,11 +337,11 @@ GlobalProperty hw_compat_2_1[] = {
>      },{
>          .driver   = "usb-mouse",
>          .property = "usb_version",
> -        .value    = stringify(1),
> +        .value    = "1",
>      },{
>          .driver   = "usb-kbd",
>          .property = "usb_version",
> -        .value    = stringify(1),
> +        .value    = "1",
>      },{
>          .driver   = "virtio-pci",
>          .property = "virtio-pci-bus-master-bug-migration",
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 4952feb476..ff14b6d4df 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -148,11 +148,11 @@ GlobalProperty pc_compat_2_12[] = {
>      },{
>          .driver   = "EPYC-" TYPE_X86_CPU,
>          .property = "xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver   = "EPYC-IBPB-" TYPE_X86_CPU,
>          .property = "xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },
>  };
>  const size_t pc_compat_2_12_len = G_N_ELEMENTS(pc_compat_2_12);
> @@ -191,7 +191,7 @@ GlobalProperty pc_compat_2_9[] = {
>      {
>          .driver   = "mch",
>          .property = "extended-tseg-mbytes",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },
>  };
>  const size_t pc_compat_2_9_len = G_N_ELEMENTS(pc_compat_2_9);
> @@ -365,75 +365,75 @@ GlobalProperty pc_compat_2_3[] = {
>      },{
>          .driver   = "qemu64" "-" TYPE_X86_CPU,
>          .property = "min-level",
> -        .value    = stringify(4),
> +        .value    = "4",
>      },{
>          .driver   = "kvm64" "-" TYPE_X86_CPU,
>          .property = "min-level",
> -        .value    = stringify(5),
> +        .value    = "5",
>      },{
>          .driver   = "pentium3" "-" TYPE_X86_CPU,
>          .property = "min-level",
> -        .value    = stringify(2),
> +        .value    = "2",
>      },{
>          .driver   = "n270" "-" TYPE_X86_CPU,
>          .property = "min-level",
> -        .value    = stringify(5),
> +        .value    = "5",
>      },{
>          .driver   = "Conroe" "-" TYPE_X86_CPU,
>          .property = "min-level",
> -        .value    = stringify(4),
> +        .value    = "4",
>      },{
>          .driver   = "Penryn" "-" TYPE_X86_CPU,
>          .property = "min-level",
> -        .value    = stringify(4),
> +        .value    = "4",
>      },{
>          .driver   = "Nehalem" "-" TYPE_X86_CPU,
>          .property = "min-level",
> -        .value    = stringify(4),
> +        .value    = "4",
>      },{
>          .driver   = "n270" "-" TYPE_X86_CPU,
>          .property = "min-xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver   = "Penryn" "-" TYPE_X86_CPU,
>          .property = "min-xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver   = "Conroe" "-" TYPE_X86_CPU,
>          .property = "min-xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver   = "Nehalem" "-" TYPE_X86_CPU,
>          .property = "min-xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver   = "Westmere" "-" TYPE_X86_CPU,
>          .property = "min-xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver   = "SandyBridge" "-" TYPE_X86_CPU,
>          .property = "min-xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver   = "IvyBridge" "-" TYPE_X86_CPU,
>          .property = "min-xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver   = "Haswell" "-" TYPE_X86_CPU,
>          .property = "min-xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver   = "Haswell-noTSX" "-" TYPE_X86_CPU,
>          .property = "min-xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver   = "Broadwell" "-" TYPE_X86_CPU,
>          .property = "min-xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver   = "Broadwell-noTSX" "-" TYPE_X86_CPU,
>          .property = "min-xlevel",
> -        .value    = stringify(0x8000000a),
> +        .value    = "0x8000000a",
>      },{
>          .driver = TYPE_X86_CPU,
>          .property = "kvm-no-smi-migration",
> @@ -566,7 +566,7 @@ GlobalProperty pc_compat_2_0[] = {
>      {
>          .driver   = "apic",
>          .property = "version",
> -        .value    = stringify(0x11),
> +        .value    = "0x11",
>      },
>      {
>          .driver   = "nec-usb-xhci",
> @@ -581,17 +581,17 @@ GlobalProperty pc_compat_2_0[] = {
>      {
>          .driver   = "pci-serial",
>          .property = "prog_if",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },
>      {
>          .driver   = "pci-serial-2x",
>          .property = "prog_if",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },
>      {
>          .driver   = "pci-serial-4x",
>          .property = "prog_if",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },
>      {
>          .driver   = "virtio-net-pci",
> @@ -629,7 +629,7 @@ GlobalProperty pc_compat_1_7[] = {
>      {
>          .driver   = "hpet",
>          .property = HPET_INTCAP,
> -        .value    = stringify(4),
> +        .value    = "4",
>      },
>  };
>  const size_t pc_compat_1_7_len = G_N_ELEMENTS(pc_compat_1_7);
> @@ -643,19 +643,19 @@ GlobalProperty pc_compat_1_6[] = {
>      },{
>          .driver   = "qemu64-" TYPE_X86_CPU,
>          .property = "model",
> -        .value    = stringify(2),
> +        .value    = "2",
>      },{
>          .driver   = "qemu32-" TYPE_X86_CPU,
>          .property = "model",
> -        .value    = stringify(3),
> +        .value    = "3",
>      },{
>          .driver   = "i440FX-pcihost",
>          .property = "short_root_bus",
> -        .value    = stringify(1),
> +        .value    = "1",
>      },{
>          .driver   = "q35-pcihost",
>          .property = "short_root_bus",
> -        .value    = stringify(1),
> +        .value    = "1",
>      },
>  };
>  const size_t pc_compat_1_6_len = G_N_ELEMENTS(pc_compat_1_6);
> @@ -665,27 +665,27 @@ GlobalProperty pc_compat_1_5[] = {
>      {
>          .driver   = "Conroe-" TYPE_X86_CPU,
>          .property = "model",
> -        .value    = stringify(2),
> +        .value    = "2",
>      },{
>          .driver   = "Conroe-" TYPE_X86_CPU,
>          .property = "min-level",
> -        .value    = stringify(2),
> +        .value    = "2",
>      },{
>          .driver   = "Penryn-" TYPE_X86_CPU,
>          .property = "model",
> -        .value    = stringify(2),
> +        .value    = "2",
>      },{
>          .driver   = "Penryn-" TYPE_X86_CPU,
>          .property = "min-level",
> -        .value    = stringify(2),
> +        .value    = "2",
>      },{
>          .driver   = "Nehalem-" TYPE_X86_CPU,
>          .property = "model",
> -        .value    = stringify(2),
> +        .value    = "2",
>      },{
>          .driver   = "Nehalem-" TYPE_X86_CPU,
>          .property = "min-level",
> -        .value    = stringify(2),
> +        .value    = "2",
>      },{
>          .driver   = "virtio-net-pci",
>          .property = "any_layout",
> @@ -697,11 +697,11 @@ GlobalProperty pc_compat_1_5[] = {
>      },{
>          .driver   = "i440FX-pcihost",
>          .property = "short_root_bus",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },{
>          .driver   = "q35-pcihost",
>          .property = "short_root_bus",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },
>  };
>  const size_t pc_compat_1_5_len = G_N_ELEMENTS(pc_compat_1_5);
> @@ -711,36 +711,36 @@ GlobalProperty pc_compat_1_4[] = {
>      {
>          .driver   = "scsi-hd",
>          .property = "discard_granularity",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },{
>          .driver   = "scsi-cd",
>          .property = "discard_granularity",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },{
>          .driver   = "scsi-disk",
>          .property = "discard_granularity",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },{
>          .driver   = "ide-hd",
>          .property = "discard_granularity",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },{
>          .driver   = "ide-cd",
>          .property = "discard_granularity",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },{
>          .driver   = "ide-drive",
>          .property = "discard_granularity",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },{
>          .driver   = "virtio-blk-pci",
>          .property = "discard_granularity",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },{
>          .driver   = "virtio-serial-pci",
>          .property = "vectors",
>          /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */
> -        .value    = stringify(0xFFFFFFFF),
> +        .value    = "0xFFFFFFFF",
>      },{
>          .driver   = "virtio-net-pci",
>          .property = "ctrl_guest_offloads",
> @@ -768,7 +768,7 @@ GlobalProperty pc_compat_1_4[] = {
>      },{
>          .driver   = "486-" TYPE_X86_CPU,
>          .property = "model",
> -        .value    = stringify(0),
> +        .value    = "0",
>      },
>      {
>          .driver = "n270" "-" TYPE_X86_CPU,
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index ed6984638e..fd20227af3 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -697,7 +697,7 @@ static void pc_i440fx_1_3_machine_options(MachineClass *m)
>          {
>              .driver   = "usb-tablet",
>              .property = "usb_version",
> -            .value    = stringify(1),
> +            .value    = "1",
>          },{
>              .driver   = "virtio-net-pci",
>              .property = "ctrl_mac_addr",
> @@ -741,11 +741,11 @@ static void pc_i440fx_1_2_machine_options(MachineClass *m)
>          },{
>              .driver   = "qxl",
>              .property = "revision",
> -            .value    = stringify(3),
> +            .value    = "3",
>          },{
>              .driver   = "qxl-vga",
>              .property = "revision",
> -            .value    = stringify(3),
> +            .value    = "3",
>          },{
>              .driver   = "VGA",
>              .property = "mmio",
> @@ -777,19 +777,19 @@ static void pc_i440fx_1_1_machine_options(MachineClass *m)
>          },{
>              .driver   = "VGA",
>              .property = "vgamem_mb",
> -            .value    = stringify(8),
> +            .value    = "8",
>          },{
>              .driver   = "vmware-svga",
>              .property = "vgamem_mb",
> -            .value    = stringify(8),
> +            .value    = "8",
>          },{
>              .driver   = "qxl-vga",
>              .property = "vgamem_mb",
> -            .value    = stringify(8),
> +            .value    = "8",
>          },{
>              .driver   = "qxl",
>              .property = "vgamem_mb",
> -            .value    = stringify(8),
> +            .value    = "8",
>          },{
>              .driver   = "virtio-blk-pci",
>              .property = "config-wce",
> @@ -876,11 +876,11 @@ static void pc_i440fx_0_14_machine_options(MachineClass *m)
>          },{
>              .driver   = "qxl",
>              .property = "revision",
> -            .value    = stringify(2),
> +            .value    = "2",
>          },{
>              .driver   = "qxl-vga",
>              .property = "revision",
> -            .value    = stringify(2),
> +            .value    = "2",
>          },
>      };
>  
> @@ -904,19 +904,19 @@ static void pc_i440fx_0_13_machine_options(MachineClass *m)
>          },{
>              .driver   = "AC97",
>              .property = "use_broken_id",
> -            .value    = stringify(1),
> +            .value    = "1",
>          },{
>              .driver   = "virtio-9p-pci",
>              .property = "vectors",
> -            .value    = stringify(0),
> +            .value    = "0",
>          },{
>              .driver   = "VGA",
>              .property = "rombar",
> -            .value    = stringify(0),
> +            .value    = "0",
>          },{
>              .driver   = "vmware-svga",
>              .property = "rombar",
> -            .value    = stringify(0),
> +            .value    = "0",
>          },
>      };
>  
> @@ -936,11 +936,11 @@ static void pc_i440fx_0_12_machine_options(MachineClass *m)
>          {
>              .driver   = "virtio-serial-pci",
>              .property = "max_ports",
> -            .value    = stringify(1),
> +            .value    = "1",
>          },{
>              .driver   = "virtio-serial-pci",
>              .property = "vectors",
> -            .value    = stringify(0),
> +            .value    = "0",
>          },{
>              .driver   = "usb-mouse",
>              .property = "serial",
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index bff42f0adb..d7d87b0ae8 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -4264,7 +4264,7 @@ static void spapr_machine_2_6_class_options(MachineClass *mc)
>          {
>              .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE,
>              .property = "ddw",
> -            .value    = stringify(off),
> +            .value    = "off",
>          },
>      };
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2019-01-08  0:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-07 19:30 [Qemu-devel] [PATCH 0/3] machine: Make compat_props arrays shorter and more readable Eduardo Habkost
2019-01-07 19:30 ` [Qemu-devel] [PATCH 1/3] spapr: Eliminate SPAPR_PCI_2_7_MMIO_WIN_SIZE macro Eduardo Habkost
2019-01-07 19:35   ` Marc-André Lureau
2019-01-08  0:07   ` David Gibson
2019-01-08  9:59   ` Cornelia Huck
2019-01-07 19:30 ` [Qemu-devel] [PATCH 2/3] machine: Eliminate unnecessary stringify() usage Eduardo Habkost
2019-01-07 19:34   ` Marc-André Lureau
2019-01-08  0:08   ` David Gibson [this message]
2019-01-08 10:03   ` Cornelia Huck
2019-01-08 14:36   ` Philippe Mathieu-Daudé
2019-01-07 19:30 ` [Qemu-devel] [PATCH 3/3] machine: Use shorter format for GlobalProperty arrays Eduardo Habkost
2019-01-07 19:40   ` Marc-André Lureau
2019-01-08  6:45   ` Gerd Hoffmann
2019-01-08 10:20     ` Cornelia Huck
2019-01-10  0:43       ` Eduardo Habkost
2019-01-08 10:21   ` Cornelia Huck
2019-01-08 14:38   ` Philippe Mathieu-Daudé

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=20190108000823.GH13339@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=anthony.perard@citrix.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).