diff mbox series

[v6,02/21] libqos: Rename i2c_send and i2c_recv

Message ID 20191129213424.6290-3-alxndr@bu.edu
State New
Headers show
Series Add virtual device fuzzing support | expand

Commit Message

Alexander Bulekov Nov. 29, 2019, 9:34 p.m. UTC
The names i2c_send and i2c_recv collide with functions defined in
hw/i2c/core.c. This causes an error when linking against libqos and
softmmu simultaneously (for example when using qtest inproc). Rename the
libqos functions to avoid this.

Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
---
 tests/libqos/i2c.c   | 10 +++++-----
 tests/libqos/i2c.h   |  4 ++--
 tests/pca9552-test.c | 10 +++++-----
 3 files changed, 12 insertions(+), 12 deletions(-)

Comments

Thomas Huth Dec. 9, 2019, 12:02 p.m. UTC | #1
On 29/11/2019 22.34, Oleinik, Alexander wrote:
> The names i2c_send and i2c_recv collide with functions defined in
> hw/i2c/core.c. This causes an error when linking against libqos and
> softmmu simultaneously (for example when using qtest inproc). Rename the
> libqos functions to avoid this.
> 
> Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
> ---
>  tests/libqos/i2c.c   | 10 +++++-----
>  tests/libqos/i2c.h   |  4 ++--
>  tests/pca9552-test.c | 10 +++++-----
>  3 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/tests/libqos/i2c.c b/tests/libqos/i2c.c
> index 156114e745..38f800dbab 100644
> --- a/tests/libqos/i2c.c
> +++ b/tests/libqos/i2c.c
> @@ -10,12 +10,12 @@
>  #include "libqos/i2c.h"
>  #include "libqtest.h"
>  
> -void i2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len)
> +void qi2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len)
>  {
>      i2cdev->bus->send(i2cdev->bus, i2cdev->addr, buf, len);
>  }
>  
> -void i2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len)
> +void qi2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len)
>  {
>      i2cdev->bus->recv(i2cdev->bus, i2cdev->addr, buf, len);
>  }

I'd prefer qos_i2c_send and qos_i2c_recv instead ... but that's just a
matter of taste.

Acked-by: Thomas Huth <thuth@redhat.com>
Stefan Hajnoczi Jan. 3, 2020, 9:58 a.m. UTC | #2
On Fri, Nov 29, 2019 at 09:34:38PM +0000, Oleinik, Alexander wrote:
> The names i2c_send and i2c_recv collide with functions defined in
> hw/i2c/core.c. This causes an error when linking against libqos and
> softmmu simultaneously (for example when using qtest inproc). Rename the
> libqos functions to avoid this.
> 
> Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
> ---
>  tests/libqos/i2c.c   | 10 +++++-----
>  tests/libqos/i2c.h   |  4 ++--
>  tests/pca9552-test.c | 10 +++++-----
>  3 files changed, 12 insertions(+), 12 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Philippe Mathieu-Daudé Jan. 3, 2020, 11:01 a.m. UTC | #3
On 12/9/19 1:02 PM, Thomas Huth wrote:
> On 29/11/2019 22.34, Oleinik, Alexander wrote:
>> The names i2c_send and i2c_recv collide with functions defined in
>> hw/i2c/core.c. This causes an error when linking against libqos and
>> softmmu simultaneously (for example when using qtest inproc). Rename the
>> libqos functions to avoid this.
>>
>> Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
>> ---
>>   tests/libqos/i2c.c   | 10 +++++-----
>>   tests/libqos/i2c.h   |  4 ++--
>>   tests/pca9552-test.c | 10 +++++-----
>>   3 files changed, 12 insertions(+), 12 deletions(-)
>>
>> diff --git a/tests/libqos/i2c.c b/tests/libqos/i2c.c
>> index 156114e745..38f800dbab 100644
>> --- a/tests/libqos/i2c.c
>> +++ b/tests/libqos/i2c.c
>> @@ -10,12 +10,12 @@
>>   #include "libqos/i2c.h"
>>   #include "libqtest.h"
>>   
>> -void i2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len)
>> +void qi2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len)
>>   {
>>       i2cdev->bus->send(i2cdev->bus, i2cdev->addr, buf, len);
>>   }
>>   
>> -void i2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len)
>> +void qi2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len)
>>   {
>>       i2cdev->bus->recv(i2cdev->bus, i2cdev->addr, buf, len);
>>   }
> 
> I'd prefer qos_i2c_send and qos_i2c_recv instead ... but that's just a
> matter of taste.
> 
> Acked-by: Thomas Huth <thuth@redhat.com>

Agreed.

Renamed qos_*:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Alexander Bulekov Jan. 5, 2020, 7:50 p.m. UTC | #4
On 200103 1201, Philippe Mathieu-Daudé wrote:
> On 12/9/19 1:02 PM, Thomas Huth wrote:
> > On 29/11/2019 22.34, Oleinik, Alexander wrote:
> > > The names i2c_send and i2c_recv collide with functions defined in
> > > hw/i2c/core.c. This causes an error when linking against libqos and
> > > softmmu simultaneously (for example when using qtest inproc). Rename the
> > > libqos functions to avoid this.
> > > 
> > > Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
> > > ---
> > >   tests/libqos/i2c.c   | 10 +++++-----
> > >   tests/libqos/i2c.h   |  4 ++--
> > >   tests/pca9552-test.c | 10 +++++-----
> > >   3 files changed, 12 insertions(+), 12 deletions(-)
> > > 
> > > diff --git a/tests/libqos/i2c.c b/tests/libqos/i2c.c
> > > index 156114e745..38f800dbab 100644
> > > --- a/tests/libqos/i2c.c
> > > +++ b/tests/libqos/i2c.c
> > > @@ -10,12 +10,12 @@
> > >   #include "libqos/i2c.h"
> > >   #include "libqtest.h"
> > > -void i2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len)
> > > +void qi2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len)
> > >   {
> > >       i2cdev->bus->send(i2cdev->bus, i2cdev->addr, buf, len);
> > >   }
> > > -void i2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len)
> > > +void qi2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len)
> > >   {
> > >       i2cdev->bus->recv(i2cdev->bus, i2cdev->addr, buf, len);
> > >   }
> > 
> > I'd prefer qos_i2c_send and qos_i2c_recv instead ... but that's just a
> > matter of taste.
> > 
> > Acked-by: Thomas Huth <thuth@redhat.com>
> 
> Agreed.
> 
> Renamed qos_*:
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
Paolo originally suggested the qi2c names in the v3 patchset, since they
are consistent with the QI2CDevice struct and the qvirtio functions.
Prior to that they had worse i2c_test... names. Scanning through the
other function names in tests/libqos, it seems most qos_ functions are
related to the internals of the qos system (eg. qos_graph_init,
qos_node_create_machine ...), while q-prefixed functions are generally
hw-specific (eg. qpci_msix_enable, qfw_cfg_read_data,
qusb_pci_init_one). Of course this pattern isn't perfectly consistent
(eg. qos_init_sdhci_mm).

Unless there is something I'm missing, I'm leaning toward leaving the
functions named qi2c_recv, qi2c_send.
diff mbox series

Patch

diff --git a/tests/libqos/i2c.c b/tests/libqos/i2c.c
index 156114e745..38f800dbab 100644
--- a/tests/libqos/i2c.c
+++ b/tests/libqos/i2c.c
@@ -10,12 +10,12 @@ 
 #include "libqos/i2c.h"
 #include "libqtest.h"
 
-void i2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len)
+void qi2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len)
 {
     i2cdev->bus->send(i2cdev->bus, i2cdev->addr, buf, len);
 }
 
-void i2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len)
+void qi2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len)
 {
     i2cdev->bus->recv(i2cdev->bus, i2cdev->addr, buf, len);
 }
@@ -23,8 +23,8 @@  void i2c_recv(QI2CDevice *i2cdev, uint8_t *buf, uint16_t len)
 void i2c_read_block(QI2CDevice *i2cdev, uint8_t reg,
                     uint8_t *buf, uint16_t len)
 {
-    i2c_send(i2cdev, &reg, 1);
-    i2c_recv(i2cdev, buf, len);
+    qi2c_send(i2cdev, &reg, 1);
+    qi2c_recv(i2cdev, buf, len);
 }
 
 void i2c_write_block(QI2CDevice *i2cdev, uint8_t reg,
@@ -33,7 +33,7 @@  void i2c_write_block(QI2CDevice *i2cdev, uint8_t reg,
     uint8_t *cmd = g_malloc(len + 1);
     cmd[0] = reg;
     memcpy(&cmd[1], buf, len);
-    i2c_send(i2cdev, cmd, len + 1);
+    qi2c_send(i2cdev, cmd, len + 1);
     g_free(cmd);
 }
 
diff --git a/tests/libqos/i2c.h b/tests/libqos/i2c.h
index 945b65b34c..c65f087834 100644
--- a/tests/libqos/i2c.h
+++ b/tests/libqos/i2c.h
@@ -47,8 +47,8 @@  struct QI2CDevice {
 void *i2c_device_create(void *i2c_bus, QGuestAllocator *alloc, void *addr);
 void add_qi2c_address(QOSGraphEdgeOptions *opts, QI2CAddress *addr);
 
-void i2c_send(QI2CDevice *dev, const uint8_t *buf, uint16_t len);
-void i2c_recv(QI2CDevice *dev, uint8_t *buf, uint16_t len);
+void qi2c_send(QI2CDevice *dev, const uint8_t *buf, uint16_t len);
+void qi2c_recv(QI2CDevice *dev, uint8_t *buf, uint16_t len);
 
 void i2c_read_block(QI2CDevice *dev, uint8_t reg,
                     uint8_t *buf, uint16_t len);
diff --git a/tests/pca9552-test.c b/tests/pca9552-test.c
index 4b800d3c3e..d80ed93cd3 100644
--- a/tests/pca9552-test.c
+++ b/tests/pca9552-test.c
@@ -32,22 +32,22 @@  static void receive_autoinc(void *obj, void *data, QGuestAllocator *alloc)
 
     pca9552_init(i2cdev);
 
-    i2c_send(i2cdev, &reg, 1);
+    qi2c_send(i2cdev, &reg, 1);
 
     /* PCA9552_LS0 */
-    i2c_recv(i2cdev, &resp, 1);
+    qi2c_recv(i2cdev, &resp, 1);
     g_assert_cmphex(resp, ==, 0x54);
 
     /* PCA9552_LS1 */
-    i2c_recv(i2cdev, &resp, 1);
+    qi2c_recv(i2cdev, &resp, 1);
     g_assert_cmphex(resp, ==, 0x55);
 
     /* PCA9552_LS2 */
-    i2c_recv(i2cdev, &resp, 1);
+    qi2c_recv(i2cdev, &resp, 1);
     g_assert_cmphex(resp, ==, 0x55);
 
     /* PCA9552_LS3 */
-    i2c_recv(i2cdev, &resp, 1);
+    qi2c_recv(i2cdev, &resp, 1);
     g_assert_cmphex(resp, ==, 0x54);
 }