qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style
@ 2014-07-31 12:28 arei.gonglei
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 1/7] usb: " arei.gonglei
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: arei.gonglei @ 2014-07-31 12:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, weidong.huang, stefanha, mst, marcel.a, luonengjun,
	armbru, lcapitulino, Gonglei, av1474, kraxel, aliguori, imammedo,
	dmitry, pbonzini, peter.huangpeng, afaerber, dgilbert

From: Gonglei <arei.gonglei@huawei.com>

Gonglei (7):
  usb: a trivial code change for more idiomatic writing style
  audio: a trivial code change for more idiomatic writing style
  isa-bus: a trivial code change for more idiomatic writing style
  a trivial code change for more idiomatic writing style
  spice: a trivial code change for more idiomatic writing style
  vl: a trivial code change for more idiomatic writing style
  vmxnet3: a trivial code change for more idiomatic writing style

 hw/audio/gus.c       |  2 +-
 hw/audio/hda-codec.c |  3 ++-
 hw/audio/sb16.c      |  6 +++---
 hw/isa/isa-bus.c     |  2 +-
 hw/net/vmxnet3.c     | 16 ++++++++--------
 hw/usb/dev-audio.c   |  2 +-
 hw/usb/dev-mtp.c     |  4 ++--
 hw/usb/hcd-ehci.c    |  2 +-
 qdev-monitor.c       |  2 +-
 qemu-char.c          |  2 +-
 ui/spice-core.c      |  4 ++--
 util/qemu-sockets.c  |  2 +-
 vl.c                 |  5 +++--
 13 files changed, 27 insertions(+), 25 deletions(-)

-- 
1.7.12.4

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 1/7] usb: a trivial code change for more idiomatic writing style
  2014-07-31 12:28 [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style arei.gonglei
@ 2014-07-31 12:28 ` arei.gonglei
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 2/7] audio: " arei.gonglei
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: arei.gonglei @ 2014-07-31 12:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, weidong.huang, stefanha, mst, marcel.a, luonengjun,
	armbru, lcapitulino, Gonglei, av1474, kraxel, aliguori, imammedo,
	dmitry, pbonzini, peter.huangpeng, afaerber, dgilbert

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/usb/dev-audio.c | 2 +-
 hw/usb/dev-mtp.c   | 4 ++--
 hw/usb/hcd-ehci.c  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c
index bfebfe9..988f6cc 100644
--- a/hw/usb/dev-audio.c
+++ b/hw/usb/dev-audio.c
@@ -371,7 +371,7 @@ static void output_callback(void *opaque, int avail)
             return;
         }
         data = streambuf_get(&s->out.buf);
-        if (NULL == data) {
+        if (data == NULL) {
             return;
         }
         AUD_write(s->out.voice, data, USBAUDIO_PACKET_SIZE);
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 384d4a5..0820046 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -832,7 +832,7 @@ static void usb_mtp_command(MTPState *s, MTPControl *c)
             return;
         }
         data_in = usb_mtp_get_object(s, c, o);
-        if (NULL == data_in) {
+        if (data_in == NULL) {
             usb_mtp_queue_result(s, RES_GENERAL_ERROR,
                                  c->trans, 0, 0, 0);
             return;
@@ -851,7 +851,7 @@ static void usb_mtp_command(MTPState *s, MTPControl *c)
             return;
         }
         data_in = usb_mtp_get_partial_object(s, c, o);
-        if (NULL == data_in) {
+        if (data_in == NULL) {
             usb_mtp_queue_result(s, RES_GENERAL_ERROR,
                                  c->trans, 0, 0, 0);
             return;
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index a00a93c..448e007 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -1596,7 +1596,7 @@ static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci, int async)
 
     entry = ehci_get_fetch_addr(ehci, async);
     q = ehci_find_queue_by_qh(ehci, entry, async);
-    if (NULL == q) {
+    if (q == NULL) {
         q = ehci_alloc_queue(ehci, entry, async);
     }
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 2/7] audio: a trivial code change for more idiomatic writing style
  2014-07-31 12:28 [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style arei.gonglei
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 1/7] usb: " arei.gonglei
@ 2014-07-31 12:28 ` arei.gonglei
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 3/7] isa-bus: " arei.gonglei
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: arei.gonglei @ 2014-07-31 12:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, weidong.huang, stefanha, mst, marcel.a, luonengjun,
	armbru, lcapitulino, Gonglei, av1474, kraxel, aliguori, imammedo,
	dmitry, pbonzini, peter.huangpeng, afaerber, dgilbert

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/audio/gus.c       | 2 +-
 hw/audio/hda-codec.c | 3 ++-
 hw/audio/sb16.c      | 6 +++---
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/audio/gus.c b/hw/audio/gus.c
index bba6840..4a43ce7 100644
--- a/hw/audio/gus.c
+++ b/hw/audio/gus.c
@@ -212,7 +212,7 @@ static int GUS_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len)
         pos += copied;
     }
 
-    if (0 == ((mode >> 4) & 1)) {
+    if (((mode >> 4) & 1) == 0) {
         DMA_release_DREQ (s->emu.gusdma);
     }
     return dma_len;
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index cbcf521..3c03ff5 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -489,8 +489,9 @@ static int hda_audio_init(HDACodecDevice *hda, const struct desc_codec *desc)
     for (i = 0; i < a->desc->nnodes; i++) {
         node = a->desc->nodes + i;
         param = hda_codec_find_param(node, AC_PAR_AUDIO_WIDGET_CAP);
-        if (NULL == param)
+        if (param == NULL) {
             continue;
+        }
         type = (param->val & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
         switch (type) {
         case AC_WID_AUD_OUT:
diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index 60c4b3b..bda26d0 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -928,7 +928,7 @@ static IO_WRITE_PROTO (dsp_write)
 /*         if (s->highspeed) */
 /*             break; */
 
-        if (0 == s->needed_bytes) {
+        if (s->needed_bytes == 0) {
             command (s, val);
 #if 0
             if (0 == s->needed_bytes) {
@@ -1212,7 +1212,7 @@ static int SB_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len)
 #endif
 
     if (till <= copy) {
-        if (0 == s->dma_auto) {
+        if (s->dma_auto == 0) {
             copy = till;
         }
     }
@@ -1224,7 +1224,7 @@ static int SB_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len)
     if (s->left_till_irq <= 0) {
         s->mixer_regs[0x82] |= (nchan & 4) ? 2 : 1;
         qemu_irq_raise (s->pic);
-        if (0 == s->dma_auto) {
+        if (s->dma_auto == 0) {
             control (s, 0);
             speaker (s, 0);
         }
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 3/7] isa-bus: a trivial code change for more idiomatic writing style
  2014-07-31 12:28 [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style arei.gonglei
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 1/7] usb: " arei.gonglei
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 2/7] audio: " arei.gonglei
@ 2014-07-31 12:28 ` arei.gonglei
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 4/7] " arei.gonglei
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: arei.gonglei @ 2014-07-31 12:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, weidong.huang, stefanha, mst, marcel.a, luonengjun,
	armbru, lcapitulino, Gonglei, av1474, kraxel, aliguori, imammedo,
	dmitry, pbonzini, peter.huangpeng, afaerber, dgilbert

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/isa/isa-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
index b28981b..851f953 100644
--- a/hw/isa/isa-bus.c
+++ b/hw/isa/isa-bus.c
@@ -50,7 +50,7 @@ ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io)
         fprintf(stderr, "Can't create a second ISA bus\n");
         return NULL;
     }
-    if (NULL == dev) {
+    if (dev == NULL) {
         dev = qdev_create(NULL, "isabus-bridge");
         qdev_init_nofail(dev);
     }
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 4/7] a trivial code change for more idiomatic writing style
  2014-07-31 12:28 [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style arei.gonglei
                   ` (2 preceding siblings ...)
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 3/7] isa-bus: " arei.gonglei
@ 2014-07-31 12:28 ` arei.gonglei
  2014-07-31 13:55   ` Dr. David Alan Gilbert
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 5/7] spice: " arei.gonglei
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: arei.gonglei @ 2014-07-31 12:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, weidong.huang, stefanha, mst, marcel.a, luonengjun,
	armbru, lcapitulino, Gonglei, av1474, kraxel, aliguori, imammedo,
	dmitry, pbonzini, peter.huangpeng, afaerber, dgilbert

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 qdev-monitor.c      | 2 +-
 qemu-char.c         | 2 +-
 util/qemu-sockets.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/qdev-monitor.c b/qdev-monitor.c
index f87f3d8..3e30d38 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -694,7 +694,7 @@ void qmp_device_del(const char *id, Error **errp)
     DeviceState *dev;
 
     dev = qdev_find_recursive(sysbus_get_default(), id);
-    if (NULL == dev) {
+    if (dev == NULL) {
         error_set(errp, QERR_DEVICE_NOT_FOUND, id);
         return;
     }
diff --git a/qemu-char.c b/qemu-char.c
index 956be49..70d5a64 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -4117,7 +4117,7 @@ void qmp_chardev_remove(const char *id, Error **errp)
     CharDriverState *chr;
 
     chr = qemu_chr_find(id);
-    if (NULL == chr) {
+    if (chr == NULL) {
         error_setg(errp, "Chardev '%s' not found", id);
         return;
     }
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 74cf078..5d38395 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -732,7 +732,7 @@ int unix_connect_opts(QemuOpts *opts, Error **errp,
     ConnectState *connect_state = NULL;
     int sock, rc;
 
-    if (NULL == path) {
+    if (path == NULL) {
         error_setg(errp, "unix connect: no path specified");
         return -1;
     }
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 5/7] spice: a trivial code change for more idiomatic writing style
  2014-07-31 12:28 [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style arei.gonglei
                   ` (3 preceding siblings ...)
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 4/7] " arei.gonglei
@ 2014-07-31 12:28 ` arei.gonglei
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 6/7] vl: " arei.gonglei
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: arei.gonglei @ 2014-07-31 12:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, weidong.huang, stefanha, mst, marcel.a, luonengjun,
	armbru, lcapitulino, Gonglei, av1474, kraxel, aliguori, imammedo,
	dmitry, pbonzini, peter.huangpeng, afaerber, dgilbert

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 ui/spice-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 7bb91e6..ff54dac 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -677,7 +677,7 @@ void qemu_spice_init(void)
 
     if (tls_port) {
         x509_dir = qemu_opt_get(opts, "x509-dir");
-        if (NULL == x509_dir) {
+        if (x509_dir == NULL) {
             x509_dir = ".";
         }
 
@@ -803,7 +803,7 @@ void qemu_spice_init(void)
 
     seamless_migration = qemu_opt_get_bool(opts, "seamless-migration", 0);
     spice_server_set_seamless_migration(spice_server, seamless_migration);
-    if (0 != spice_server_init(spice_server, &core_interface)) {
+    if (spice_server_init(spice_server, &core_interface) != 0) {
         error_report("failed to initialize spice server");
         exit(1);
     };
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 6/7] vl: a trivial code change for more idiomatic writing style
  2014-07-31 12:28 [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style arei.gonglei
                   ` (4 preceding siblings ...)
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 5/7] spice: " arei.gonglei
@ 2014-07-31 12:28 ` arei.gonglei
  2014-07-31 12:29 ` [Qemu-devel] [PATCH 7/7] vmxnet3: " arei.gonglei
  2014-07-31 12:39 ` [Qemu-devel] [PATCH for-2.2 0/7] " Peter Maydell
  7 siblings, 0 replies; 16+ messages in thread
From: arei.gonglei @ 2014-07-31 12:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, weidong.huang, stefanha, mst, marcel.a, luonengjun,
	armbru, lcapitulino, Gonglei, av1474, kraxel, aliguori, imammedo,
	dmitry, pbonzini, peter.huangpeng, afaerber, dgilbert

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 vl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/vl.c b/vl.c
index fe451aa..69f0f20 100644
--- a/vl.c
+++ b/vl.c
@@ -1136,7 +1136,7 @@ static int drive_init_func(QemuOpts *opts, void *opaque)
 
 static int drive_enable_snapshot(QemuOpts *opts, void *opaque)
 {
-    if (NULL == qemu_opt_get(opts, "snapshot")) {
+    if (qemu_opt_get(opts, "snapshot") == NULL) {
         qemu_opt_set(opts, "snapshot", "on");
     }
     return 0;
@@ -2488,8 +2488,9 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline))
         loc_push_restore(&conf->loc);
         rc = func(conf->cmdline);
         loc_pop(&conf->loc);
-        if (0 != rc)
+        if (rc != 0) {
             return rc;
+        }
     }
     return 0;
 }
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Qemu-devel] [PATCH 7/7] vmxnet3: a trivial code change for more idiomatic writing style
  2014-07-31 12:28 [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style arei.gonglei
                   ` (5 preceding siblings ...)
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 6/7] vl: " arei.gonglei
@ 2014-07-31 12:29 ` arei.gonglei
  2014-08-04 11:08   ` Stefan Hajnoczi
  2014-07-31 12:39 ` [Qemu-devel] [PATCH for-2.2 0/7] " Peter Maydell
  7 siblings, 1 reply; 16+ messages in thread
From: arei.gonglei @ 2014-07-31 12:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, weidong.huang, stefanha, mst, marcel.a, luonengjun,
	armbru, lcapitulino, Gonglei, av1474, kraxel, aliguori, imammedo,
	dmitry, pbonzini, peter.huangpeng, afaerber, dgilbert

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/net/vmxnet3.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 77bea6f..34c5aff 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1009,7 +1009,7 @@ vmxnet3_indicate_packet(VMXNET3State *s)
 
         vmxnet3_dump_rx_descr(&rxd);
 
-        if (0 != ready_rxcd_pa) {
+        if (ready_rxcd_pa != 0) {
             cpu_physical_memory_write(ready_rxcd_pa, &rxcd, sizeof(rxcd));
         }
 
@@ -1020,7 +1020,7 @@ vmxnet3_indicate_packet(VMXNET3State *s)
         rxcd.gen = new_rxcd_gen;
         rxcd.rqID = RXQ_IDX + rx_ridx * s->rxq_num;
 
-        if (0 == bytes_left) {
+        if (bytes_left == 0) {
             vmxnet3_rx_update_descr(s->rx_pkt, &rxcd);
         }
 
@@ -1038,16 +1038,16 @@ vmxnet3_indicate_packet(VMXNET3State *s)
         num_frags++;
     }
 
-    if (0 != ready_rxcd_pa) {
+    if (ready_rxcd_pa != 0) {
         rxcd.eop = 1;
-        rxcd.err = (0 != bytes_left);
+        rxcd.err = (bytes_left != 0);
         cpu_physical_memory_write(ready_rxcd_pa, &rxcd, sizeof(rxcd));
 
         /* Flush RX descriptor changes */
         smp_wmb();
     }
 
-    if (0 != new_rxcd_pa) {
+    if (new_rxcd_pa != 0) {
         vmxnet3_revert_rxc_descr(s, RXQ_IDX);
     }
 
@@ -1190,8 +1190,8 @@ static void vmxnet3_update_mcast_filters(VMXNET3State *s)
     s->mcast_list_len = list_bytes / sizeof(s->mcast_list[0]);
 
     s->mcast_list = g_realloc(s->mcast_list, list_bytes);
-    if (NULL == s->mcast_list) {
-        if (0 == s->mcast_list_len) {
+    if (s->mcast_list == NULL) {
+        if (s->mcast_list_len == 0) {
             VMW_CFPRN("Current multicast list is empty");
         } else {
             VMW_ERPRN("Failed to allocate multicast list of %d elements",
@@ -1667,7 +1667,7 @@ vmxnet3_io_bar1_write(void *opaque,
          * memory address. We save it to temp variable and set the
          * shared address only after we get the high part
          */
-        if (0 == val) {
+        if (val == 0) {
             s->device_active = false;
         }
         s->temp_shared_guest_driver_memory = val;
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style
  2014-07-31 12:28 [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style arei.gonglei
                   ` (6 preceding siblings ...)
  2014-07-31 12:29 ` [Qemu-devel] [PATCH 7/7] vmxnet3: " arei.gonglei
@ 2014-07-31 12:39 ` Peter Maydell
  2014-07-31 12:46   ` Gonglei (Arei)
  2014-07-31 12:55   ` Peter Crosthwaite
  7 siblings, 2 replies; 16+ messages in thread
From: Peter Maydell @ 2014-07-31 12:39 UTC (permalink / raw)
  To: Gonglei (Arei)
  Cc: Huangweidong (C), Stefan Hajnoczi, Michael S. Tsirkin,
	Marcel Apfelbaum, Luonengjun, QEMU Developers, Markus Armbruster,
	Vassili Karpov, Gerd Hoffmann, Anthony Liguori, Igor Mammedov,
	Dmitry Fleytman, Paolo Bonzini, peter.huangpeng, Luiz Capitulino,
	Andreas Färber, Dr. David Alan Gilbert

On 31 July 2014 13:28,  <arei.gonglei@huawei.com> wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> Gonglei (7):
>   usb: a trivial code change for more idiomatic writing style
>   audio: a trivial code change for more idiomatic writing style
>   isa-bus: a trivial code change for more idiomatic writing style
>   a trivial code change for more idiomatic writing style
>   spice: a trivial code change for more idiomatic writing style
>   vl: a trivial code change for more idiomatic writing style
>   vmxnet3: a trivial code change for more idiomatic writing style

Hi. I think we could make the commit messages here
a bit more specific:
===
$WHATEVER: don't use 'Yoda conditions'

'Yoda conditions' are not part of idiomatic QEMU coding
style, so rewrite them in the more usual order.
===

thanks
-- PMM

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style
  2014-07-31 12:39 ` [Qemu-devel] [PATCH for-2.2 0/7] " Peter Maydell
@ 2014-07-31 12:46   ` Gonglei (Arei)
  2014-07-31 12:55   ` Peter Crosthwaite
  1 sibling, 0 replies; 16+ messages in thread
From: Gonglei (Arei) @ 2014-07-31 12:46 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Huangweidong (C), Stefan Hajnoczi, Michael S. Tsirkin,
	Marcel Apfelbaum, Luonengjun, QEMU Developers, Markus Armbruster,
	Vassili Karpov, Gerd Hoffmann, Anthony Liguori, Igor Mammedov,
	Dmitry Fleytman, Paolo Bonzini, Huangpeng (Peter),
	Luiz Capitulino, Andreas Färber, Dr. David Alan Gilbert

Hi, PMM

> -----Original Message-----
> From: Peter Maydell [mailto:peter.maydell@linaro.org]
> Sent: Thursday, July 31, 2014 8:40 PM
> Subject: Re: [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing
> style
> 
> On 31 July 2014 13:28,  <arei.gonglei@huawei.com> wrote:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > Gonglei (7):
> >   usb: a trivial code change for more idiomatic writing style
> >   audio: a trivial code change for more idiomatic writing style
> >   isa-bus: a trivial code change for more idiomatic writing style
> >   a trivial code change for more idiomatic writing style
> >   spice: a trivial code change for more idiomatic writing style
> >   vl: a trivial code change for more idiomatic writing style
> >   vmxnet3: a trivial code change for more idiomatic writing style
> 
> Hi. I think we could make the commit messages here
> a bit more specific:
> ===
> $WHATEVER: don't use 'Yoda conditions'
> 
> 'Yoda conditions' are not part of idiomatic QEMU coding
> style, so rewrite them in the more usual order.
> ===
> 
> thanks
> -- PMM

Hmm...Yes, Thanks! 

Actually I got the idea from Eric's reviewing comments for my
bootindex patch serials.

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style
  2014-07-31 12:39 ` [Qemu-devel] [PATCH for-2.2 0/7] " Peter Maydell
  2014-07-31 12:46   ` Gonglei (Arei)
@ 2014-07-31 12:55   ` Peter Crosthwaite
  2014-07-31 13:04     ` Gonglei (Arei)
  1 sibling, 1 reply; 16+ messages in thread
From: Peter Crosthwaite @ 2014-07-31 12:55 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Huangweidong (C), Anthony Liguori, Marcel Apfelbaum,
	Michael S. Tsirkin, Luonengjun, QEMU Developers,
	Markus Armbruster, Gonglei (Arei), Vassili Karpov, Gerd Hoffmann,
	Stefan Hajnoczi, Paolo Bonzini, Dmitry Fleytman, Igor Mammedov,
	peter.huangpeng, Luiz Capitulino, Andreas Färber,
	Dr. David Alan Gilbert

On Thu, Jul 31, 2014 at 10:39 PM, Peter Maydell
<peter.maydell@linaro.org> wrote:
> On 31 July 2014 13:28,  <arei.gonglei@huawei.com> wrote:
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> Gonglei (7):
>>   usb: a trivial code change for more idiomatic writing style
>>   audio: a trivial code change for more idiomatic writing style
>>   isa-bus: a trivial code change for more idiomatic writing style
>>   a trivial code change for more idiomatic writing style
>>   spice: a trivial code change for more idiomatic writing style
>>   vl: a trivial code change for more idiomatic writing style
>>   vmxnet3: a trivial code change for more idiomatic writing style
>
> Hi. I think we could make the commit messages here
> a bit more specific:
> ===
> $WHATEVER: don't use 'Yoda conditions'
>
> 'Yoda conditions' are not part of idiomatic QEMU coding
> style, so rewrite them in the more usual order.

Should this series include a patch to CODING_STYLE?

Regards,
Peter

> ===
>
> thanks
> -- PMM
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style
  2014-07-31 12:55   ` Peter Crosthwaite
@ 2014-07-31 13:04     ` Gonglei (Arei)
  0 siblings, 0 replies; 16+ messages in thread
From: Gonglei (Arei) @ 2014-07-31 13:04 UTC (permalink / raw)
  To: Peter Crosthwaite, Peter Maydell
  Cc: Huangweidong (C), Anthony Liguori, Marcel Apfelbaum,
	Michael S. Tsirkin, Luonengjun, QEMU Developers,
	Markus Armbruster, Vassili Karpov, Gerd Hoffmann, Stefan Hajnoczi,
	Paolo Bonzini, Dmitry Fleytman, Igor Mammedov, Huangpeng (Peter),
	Luiz Capitulino, Andreas Färber, Dr. David Alan Gilbert

Hi,

> Subject: Re: [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more
> idiomatic writing style
> 
> On Thu, Jul 31, 2014 at 10:39 PM, Peter Maydell
> <peter.maydell@linaro.org> wrote:
> > On 31 July 2014 13:28,  <arei.gonglei@huawei.com> wrote:
> >> From: Gonglei <arei.gonglei@huawei.com>
> >>
> >> Gonglei (7):
> >>   usb: a trivial code change for more idiomatic writing style
> >>   audio: a trivial code change for more idiomatic writing style
> >>   isa-bus: a trivial code change for more idiomatic writing style
> >>   a trivial code change for more idiomatic writing style
> >>   spice: a trivial code change for more idiomatic writing style
> >>   vl: a trivial code change for more idiomatic writing style
> >>   vmxnet3: a trivial code change for more idiomatic writing style
> >
> > Hi. I think we could make the commit messages here
> > a bit more specific:
> > ===
> > $WHATEVER: don't use 'Yoda conditions'
> >
> > 'Yoda conditions' are not part of idiomatic QEMU coding
> > style, so rewrite them in the more usual order.
> 
> Should this series include a patch to CODING_STYLE?
> 
Yes, good idea IMHO! 

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 4/7] a trivial code change for more idiomatic writing style
  2014-07-31 12:28 ` [Qemu-devel] [PATCH 4/7] " arei.gonglei
@ 2014-07-31 13:55   ` Dr. David Alan Gilbert
  2014-07-31 13:59     ` Peter Maydell
  0 siblings, 1 reply; 16+ messages in thread
From: Dr. David Alan Gilbert @ 2014-07-31 13:55 UTC (permalink / raw)
  To: arei.gonglei
  Cc: peter.maydell, weidong.huang, stefanha, mst, marcel.a, luonengjun,
	qemu-devel, armbru, av1474, kraxel, aliguori, imammedo, dmitry,
	pbonzini, peter.huangpeng, lcapitulino, afaerber

* arei.gonglei@huawei.com (arei.gonglei@huawei.com) wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  qdev-monitor.c      | 2 +-
>  qemu-char.c         | 2 +-
>  util/qemu-sockets.c | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index f87f3d8..3e30d38 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -694,7 +694,7 @@ void qmp_device_del(const char *id, Error **errp)
>      DeviceState *dev;
>  
>      dev = qdev_find_recursive(sysbus_get_default(), id);
> -    if (NULL == dev) {
> +    if (dev == NULL) {

I know people who write it as 'NULL == dev' on purpose,
because that will cause an error if you accidentally type a single =
where as 'dev = NULL'  will just cause confusion.

Dave
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 4/7] a trivial code change for more idiomatic writing style
  2014-07-31 13:55   ` Dr. David Alan Gilbert
@ 2014-07-31 13:59     ` Peter Maydell
  2014-07-31 14:49       ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Maydell @ 2014-07-31 13:59 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: Huangweidong (C), Stefan Hajnoczi, Michael S. Tsirkin,
	Marcel Apfelbaum, Luonengjun, QEMU Developers, Markus Armbruster,
	Gonglei (Arei), Vassili Karpov, Gerd Hoffmann, Anthony Liguori,
	Igor Mammedov, Dmitry Fleytman, Paolo Bonzini, peter.huangpeng,
	Luiz Capitulino, Andreas Färber

On 31 July 2014 14:55, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> * arei.gonglei@huawei.com (arei.gonglei@huawei.com) wrote:
>> --- a/qdev-monitor.c
>> +++ b/qdev-monitor.c
>> @@ -694,7 +694,7 @@ void qmp_device_del(const char *id, Error **errp)
>>      DeviceState *dev;
>>
>>      dev = qdev_find_recursive(sysbus_get_default(), id);
>> -    if (NULL == dev) {
>> +    if (dev == NULL) {
>
> I know people who write it as 'NULL == dev' on purpose,
> because that will cause an error if you accidentally type a single =
> where as 'dev = NULL'  will just cause confusion.

Yes, this is the motivation for Yoda conditionals. But it only
makes sense if you don't have a compiler with a sensible
warning configuration. For QEMU you will get an error if you
write "dev = NULL" :

error: suggest parentheses around assignment used as truth value
[-Werror=parentheses]

so we don't need to get people to contort their code like this.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 4/7] a trivial code change for more idiomatic writing style
  2014-07-31 13:59     ` Peter Maydell
@ 2014-07-31 14:49       ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 16+ messages in thread
From: Dr. David Alan Gilbert @ 2014-07-31 14:49 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Huangweidong (C), Stefan Hajnoczi, Michael S. Tsirkin,
	Marcel Apfelbaum, Luonengjun, QEMU Developers, Markus Armbruster,
	Gonglei (Arei), Vassili Karpov, Gerd Hoffmann, Anthony Liguori,
	Igor Mammedov, Dmitry Fleytman, Paolo Bonzini, peter.huangpeng,
	Luiz Capitulino, Andreas F?rber

* Peter Maydell (peter.maydell@linaro.org) wrote:
> On 31 July 2014 14:55, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> > * arei.gonglei@huawei.com (arei.gonglei@huawei.com) wrote:
> >> --- a/qdev-monitor.c
> >> +++ b/qdev-monitor.c
> >> @@ -694,7 +694,7 @@ void qmp_device_del(const char *id, Error **errp)
> >>      DeviceState *dev;
> >>
> >>      dev = qdev_find_recursive(sysbus_get_default(), id);
> >> -    if (NULL == dev) {
> >> +    if (dev == NULL) {
> >
> > I know people who write it as 'NULL == dev' on purpose,
> > because that will cause an error if you accidentally type a single =
> > where as 'dev = NULL'  will just cause confusion.
> 
> Yes, this is the motivation for Yoda conditionals. But it only
> makes sense if you don't have a compiler with a sensible
> warning configuration. For QEMU you will get an error if you
> write "dev = NULL" :
> 
> error: suggest parentheses around assignment used as truth value
> [-Werror=parentheses]
> 
> so we don't need to get people to contort their code like this.


OK, that's fair enough.

Dave

> thanks
> -- PMM
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] [PATCH 7/7] vmxnet3: a trivial code change for more idiomatic writing style
  2014-07-31 12:29 ` [Qemu-devel] [PATCH 7/7] vmxnet3: " arei.gonglei
@ 2014-08-04 11:08   ` Stefan Hajnoczi
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Hajnoczi @ 2014-08-04 11:08 UTC (permalink / raw)
  To: arei.gonglei
  Cc: peter.maydell, weidong.huang, mst, marcel.a, luonengjun,
	qemu-devel, armbru, av1474, kraxel, aliguori, imammedo, dmitry,
	pbonzini, peter.huangpeng, lcapitulino, afaerber, dgilbert

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

On Thu, Jul 31, 2014 at 08:29:00PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  hw/net/vmxnet3.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-08-04 11:09 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-31 12:28 [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style arei.gonglei
2014-07-31 12:28 ` [Qemu-devel] [PATCH 1/7] usb: " arei.gonglei
2014-07-31 12:28 ` [Qemu-devel] [PATCH 2/7] audio: " arei.gonglei
2014-07-31 12:28 ` [Qemu-devel] [PATCH 3/7] isa-bus: " arei.gonglei
2014-07-31 12:28 ` [Qemu-devel] [PATCH 4/7] " arei.gonglei
2014-07-31 13:55   ` Dr. David Alan Gilbert
2014-07-31 13:59     ` Peter Maydell
2014-07-31 14:49       ` Dr. David Alan Gilbert
2014-07-31 12:28 ` [Qemu-devel] [PATCH 5/7] spice: " arei.gonglei
2014-07-31 12:28 ` [Qemu-devel] [PATCH 6/7] vl: " arei.gonglei
2014-07-31 12:29 ` [Qemu-devel] [PATCH 7/7] vmxnet3: " arei.gonglei
2014-08-04 11:08   ` Stefan Hajnoczi
2014-07-31 12:39 ` [Qemu-devel] [PATCH for-2.2 0/7] " Peter Maydell
2014-07-31 12:46   ` Gonglei (Arei)
2014-07-31 12:55   ` Peter Crosthwaite
2014-07-31 13:04     ` Gonglei (Arei)

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).