[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 28/37] qdev: use g_strcmp0() instead of open-coding it
From: |
Eduardo Habkost |
Subject: |
Re: [PATCH v4 28/37] qdev: use g_strcmp0() instead of open-coding it |
Date: |
Wed, 20 Nov 2019 14:10:50 -0300 |
On Wed, Nov 20, 2019 at 05:25:47PM +0100, Philippe Mathieu-Daudé wrote:
> On 11/20/19 4:24 PM, Marc-André Lureau wrote:
> > Minor code simplification.
> >
> > Signed-off-by: Marc-André Lureau <address@hidden>
> > ---
> > hw/core/qdev.c | 7 ++-----
> > 1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> > index cf1ba28fe3..c79befc865 100644
> > --- a/hw/core/qdev.c
> > +++ b/hw/core/qdev.c
> > @@ -394,11 +394,8 @@ static NamedGPIOList
> > *qdev_get_named_gpio_list(DeviceState *dev,
> > NamedGPIOList *ngl;
> > QLIST_FOREACH(ngl, &dev->gpios, node) {
> > - /* NULL is a valid and matchable name, otherwise do a normal
> > - * strcmp match.
> > - */
> > - if ((!ngl->name && !name) ||
> > - (name && ngl->name && strcmp(name, ngl->name) == 0)) {
> > + /* NULL is a valid and matchable name. */
> > + if (g_strcmp0(name, ngl->name) == 0) {
>
> Cocci pattern?
This seems tricky because there are many different ways of
writing an equivalent expression. I tried to catch a few
variations, but the script below didn't find any other
occurrences except for the one being touched by this patch.
@@
expression A, B;
@@
(
-(!A && !B) || (A && B && !strcmp(A, B))
+!g_strcmp0(A, B)
|
-(!B && !A) || (A && B && !strcmp(A, B))
+!g_strcmp0(A, B)
|
-(!A && !B) || (B && A && !strcmp(A, B))
+!g_strcmp0(A, B)
|
-(!B && !A) || (B && A && !strcmp(A, B))
+!g_strcmp0(A, B)
|
-(!A && !B) || (B && A && strcmp(A, B) == 0)
+!g_strcmp0(A, B)
|
-(!B && !A) || (B && A && strcmp(A, B) == 0)
+!g_strcmp0(A, B)
|
-(!A && !B) || (A && B && strcmp(A, B) == 0)
+!g_strcmp0(A, B)
|
-(!B && !A) || (A && B && strcmp(A, B) == 0)
+!g_strcmp0(A, B)
)
--
Eduardo
- [PATCH v4 22/37] vmmouse: replace PROP_PTR with PROP_LINK, (continued)
- [PATCH v4 22/37] vmmouse: replace PROP_PTR with PROP_LINK, Marc-André Lureau, 2019/11/20
- [PATCH v4 23/37] lance: replace PROP_PTR with PROP_LINK, Marc-André Lureau, 2019/11/20
- [PATCH v4 24/37] etraxfs: remove PROP_PTR usage, Marc-André Lureau, 2019/11/20
- [PATCH v4 25/37] dp8393x: replace PROP_PTR with PROP_LINK, Marc-André Lureau, 2019/11/20
- [PATCH v4 26/37] leon3: use qemu_irq framework instead of callback as property, Marc-André Lureau, 2019/11/20
- [PATCH v4 27/37] leon3: use qdev gpio facilities for the PIL, Marc-André Lureau, 2019/11/20
- [PATCH v4 28/37] qdev: use g_strcmp0() instead of open-coding it, Marc-André Lureau, 2019/11/20
- [PATCH v4 29/37] RFC: mips/cps: fix setting saar property, Marc-André Lureau, 2019/11/20
- [PATCH v4 30/37] cris: improve passing PIC interrupt vector to the CPU, Marc-André Lureau, 2019/11/20
- [PATCH v4 31/37] smbus-eeprom: remove PROP_PTR, Marc-André Lureau, 2019/11/20
- Re: [PATCH v4 31/37] smbus-eeprom: remove PROP_PTR, Philippe Mathieu-Daudé, 2019/11/22