* [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions
@ 2014-08-04 9:19 arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 1/8] CODING_STYLE: Section about conditional statement arei.gonglei
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: arei.gonglei @ 2014-08-04 9:19 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, peter.crosthwaite, 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>
$WHATEVER: don't use 'Yoda conditions'
'Yoda conditions' are not part of idiomatic QEMU coding
style, so rewrite them in the more usual order.
v4:
- trivial typo for patch 1/8 suggested by Eric, thanks.
v3:
- rewrite CODINT_STYLE file suggested by Eric, thanks.
- rename the patch serials.
- imitate nearby code about using '!value' or 'value == NULL' at
every patch suggested by Markus.
v2:
- add more specific commit messages suggested by PMM, thanks.
- introduce section of conditional statement to CODING_STYLE.
Gonglei (8):
CODING_STYLE: Section about conditional statement
usb: don't use 'Yoda conditions'
audio: don't use 'Yoda conditions'
isa-bus: don't use 'Yoda conditions'
don't use 'Yoda conditions'
spice: don't use 'Yoda conditions'
vl: don't use 'Yoda conditions'
vmxnet3: don't use 'Yoda conditions'
CODING_STYLE | 14 ++++++++++++++
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 +++--
14 files changed, 41 insertions(+), 25 deletions(-)
--
1.7.12.4
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v4 1/8] CODING_STYLE: Section about conditional statement
2014-08-04 9:19 [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions arei.gonglei
@ 2014-08-04 9:19 ` arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 2/8] usb: don't use 'Yoda conditions' arei.gonglei
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: arei.gonglei @ 2014-08-04 9:19 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, peter.crosthwaite, 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>
Yoda conditions lack readability, and QEMU has a
strict compiler configuration for checking a common
mistake like "if (dev = NULL)". Make it a written rule.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
CODING_STYLE | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/CODING_STYLE b/CODING_STYLE
index 4280945..d46cfa5 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -91,3 +91,17 @@ Mixed declarations (interleaving statements and declarations within blocks)
are not allowed; declarations should be at the beginning of blocks. In other
words, the code should not generate warnings if using GCC's
-Wdeclaration-after-statement option.
+
+6. Conditional statements
+
+When comparing a variable for (in)equality with a constant, list the
+constant on the right, as in:
+
+if (a == 1) {
+ /* Reads like: "If a equals 1" */
+ do_something();
+}
+
+Rationale: Yoda conditions (as in 'if (1 == a)') are awkward to read.
+Besides, good compilers already warn users when '==' is mis-typed as '=',
+even when the constant is on the right.
--
1.7.12.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v4 2/8] usb: don't use 'Yoda conditions'
2014-08-04 9:19 [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 1/8] CODING_STYLE: Section about conditional statement arei.gonglei
@ 2014-08-04 9:19 ` arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 3/8] audio: " arei.gonglei
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: arei.gonglei @ 2014-08-04 9:19 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, peter.crosthwaite, 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>
imitate nearby code about using '!value' or 'value == NULL'
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..7b9957b 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) {
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] 11+ messages in thread
* [Qemu-devel] [PATCH v4 3/8] audio: don't use 'Yoda conditions'
2014-08-04 9:19 [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 1/8] CODING_STYLE: Section about conditional statement arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 2/8] usb: don't use 'Yoda conditions' arei.gonglei
@ 2014-08-04 9:19 ` arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 4/8] isa-bus: " arei.gonglei
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: arei.gonglei @ 2014-08-04 9:19 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, peter.crosthwaite, 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>
imitate nearby code about using '!value' or 'value == NULL'
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] 11+ messages in thread
* [Qemu-devel] [PATCH v4 4/8] isa-bus: don't use 'Yoda conditions'
2014-08-04 9:19 [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions arei.gonglei
` (2 preceding siblings ...)
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 3/8] audio: " arei.gonglei
@ 2014-08-04 9:19 ` arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 5/8] " arei.gonglei
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: arei.gonglei @ 2014-08-04 9:19 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, peter.crosthwaite, 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>
imitate nearby code about using '!value' or 'value == NULL'
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..cc85e53 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) {
dev = qdev_create(NULL, "isabus-bridge");
qdev_init_nofail(dev);
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v4 5/8] don't use 'Yoda conditions'
2014-08-04 9:19 [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions arei.gonglei
` (3 preceding siblings ...)
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 4/8] isa-bus: " arei.gonglei
@ 2014-08-04 9:19 ` arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 6/8] spice: " arei.gonglei
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: arei.gonglei @ 2014-08-04 9:19 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, peter.crosthwaite, 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>
imitate nearby code about using '!value' or 'value == NULL'
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..81a4e9b 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) {
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] 11+ messages in thread
* [Qemu-devel] [PATCH v4 6/8] spice: don't use 'Yoda conditions'
2014-08-04 9:19 [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions arei.gonglei
` (4 preceding siblings ...)
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 5/8] " arei.gonglei
@ 2014-08-04 9:19 ` arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 7/8] vl: " arei.gonglei
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: arei.gonglei @ 2014-08-04 9:19 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, peter.crosthwaite, 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>
imitate nearby code about using '!value' or 'value == NULL'
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..1a2fb4b 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) {
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] 11+ messages in thread
* [Qemu-devel] [PATCH v4 7/8] vl: don't use 'Yoda conditions'
2014-08-04 9:19 [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions arei.gonglei
` (5 preceding siblings ...)
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 6/8] spice: " arei.gonglei
@ 2014-08-04 9:19 ` arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 8/8] vmxnet3: " arei.gonglei
2014-08-05 13:01 ` [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions Eric Blake
8 siblings, 0 replies; 11+ messages in thread
From: arei.gonglei @ 2014-08-04 9:19 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, peter.crosthwaite, 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>
imitate nearby code about using '!value' or 'value == NULL'
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..04c5abd 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) {
return rc;
+ }
}
return 0;
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v4 8/8] vmxnet3: don't use 'Yoda conditions'
2014-08-04 9:19 [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions arei.gonglei
` (6 preceding siblings ...)
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 7/8] vl: " arei.gonglei
@ 2014-08-04 9:19 ` arei.gonglei
2014-08-05 13:01 ` [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions Eric Blake
8 siblings, 0 replies; 11+ messages in thread
From: arei.gonglei @ 2014-08-04 9:19 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, peter.crosthwaite, 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>
imitate nearby code about using '!value' or 'value == NULL'
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..588149d 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) {
+ 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] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions
2014-08-04 9:19 [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions arei.gonglei
` (7 preceding siblings ...)
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 8/8] vmxnet3: " arei.gonglei
@ 2014-08-05 13:01 ` Eric Blake
2014-08-06 1:25 ` Gonglei (Arei)
8 siblings, 1 reply; 11+ messages in thread
From: Eric Blake @ 2014-08-05 13:01 UTC (permalink / raw)
To: arei.gonglei, qemu-devel
Cc: peter.maydell, peter.crosthwaite, weidong.huang, stefanha, mst,
qemu-trivial, marcel.a, luonengjun, armbru, lcapitulino, av1474,
kraxel, aliguori, imammedo, dmitry, pbonzini, peter.huangpeng,
afaerber, dgilbert
[-- Attachment #1: Type: text/plain, Size: 877 bytes --]
On 08/04/2014 03:19 AM, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> $WHATEVER: don't use 'Yoda conditions'
>
> 'Yoda conditions' are not part of idiomatic QEMU coding
> style, so rewrite them in the more usual order.
>
> v4:
> - trivial typo for patch 1/8 suggested by Eric, thanks.
Series: Reviewed-by: Eric Blake <eblake@redhat.com>
Adding qemu-trivial in cc.
> Gonglei (8):
> CODING_STYLE: Section about conditional statement
> usb: don't use 'Yoda conditions'
> audio: don't use 'Yoda conditions'
> isa-bus: don't use 'Yoda conditions'
> don't use 'Yoda conditions'
> spice: don't use 'Yoda conditions'
> vl: don't use 'Yoda conditions'
> vmxnet3: don't use 'Yoda conditions'
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions
2014-08-05 13:01 ` [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions Eric Blake
@ 2014-08-06 1:25 ` Gonglei (Arei)
0 siblings, 0 replies; 11+ messages in thread
From: Gonglei (Arei) @ 2014-08-06 1:25 UTC (permalink / raw)
To: Eric Blake, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com,
Huangweidong (C), stefanha@redhat.com, mst@redhat.com,
qemu-trivial, marcel.a@redhat.com, Luonengjun, armbru@redhat.com,
lcapitulino@redhat.com, av1474@comtv.ru, kraxel@redhat.com,
aliguori@amazon.com, imammedo@redhat.com, dmitry@daynix.com,
pbonzini@redhat.com, Huangpeng (Peter), afaerber@suse.de,
dgilbert@redhat.com
Hi,
> >
> > $WHATEVER: don't use 'Yoda conditions'
> >
> > 'Yoda conditions' are not part of idiomatic QEMU coding
> > style, so rewrite them in the more usual order.
> >
> > v4:
> > - trivial typo for patch 1/8 suggested by Eric, thanks.
>
> Series: Reviewed-by: Eric Blake <eblake@redhat.com>
>
> Adding qemu-trivial in cc.
>
Thanks for review, Eric.
> > Gonglei (8):
> > CODING_STYLE: Section about conditional statement
> > usb: don't use 'Yoda conditions'
> > audio: don't use 'Yoda conditions'
> > isa-bus: don't use 'Yoda conditions'
> > don't use 'Yoda conditions'
> > spice: don't use 'Yoda conditions'
> > vl: don't use 'Yoda conditions'
> > vmxnet3: don't use 'Yoda conditions'
> >
>
>
> --
> Eric Blake eblake redhat com +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
Best regards,
-Gonglei
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-08-06 1:25 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-04 9:19 [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 1/8] CODING_STYLE: Section about conditional statement arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 2/8] usb: don't use 'Yoda conditions' arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 3/8] audio: " arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 4/8] isa-bus: " arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 5/8] " arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 6/8] spice: " arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 7/8] vl: " arei.gonglei
2014-08-04 9:19 ` [Qemu-devel] [PATCH v4 8/8] vmxnet3: " arei.gonglei
2014-08-05 13:01 ` [Qemu-devel] [PATCH v4 0/8] don't use Yoda conditions Eric Blake
2014-08-06 1:25 ` 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).