diff mbox series

[v2,04/12] veth: Compile with -Wextra

Message ID 20210209014457.108301-5-aik@ozlabs.ru
State Accepted
Headers show
Series Compile with -Wextra | expand

Commit Message

Alexey Kardashevskiy Feb. 9, 2021, 1:44 a.m. UTC
-Wextra enables a bunch of rather useful checks which this fixes.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 lib/libveth/veth.h | 2 +-
 lib/libveth/veth.c | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Thomas Huth Feb. 10, 2021, 8:11 a.m. UTC | #1
On 09/02/2021 02.44, Alexey Kardashevskiy wrote:
> -Wextra enables a bunch of rather useful checks which this fixes.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>   lib/libveth/veth.h | 2 +-
>   lib/libveth/veth.c | 8 ++++++--
>   2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/libveth/veth.h b/lib/libveth/veth.h
> index 23af0eab6211..6a1cb4cb5790 100644
> --- a/lib/libveth/veth.h
> +++ b/lib/libveth/veth.h
> @@ -16,7 +16,7 @@
>   #include <stdint.h>
>   #include <netdriver.h>
>   
> -extern net_driver_t *libveth_open(char *mac_addr, int mac_len, char *reg, int reg_len);
> +extern net_driver_t *libveth_open(char *mac_addr, unsigned mac_len, char *reg, unsigned reg_len);
>   extern void libveth_close(net_driver_t *driver);
>   extern int libveth_read(char *buf, int len, net_driver_t *driver);
>   extern int libveth_write(char *buf, int len, net_driver_t *driver);
> diff --git a/lib/libveth/veth.c b/lib/libveth/veth.c
> index 748730854035..a8e19ba41764 100644
> --- a/lib/libveth/veth.c
> +++ b/lib/libveth/veth.c
> @@ -164,7 +164,7 @@ static int veth_term(net_driver_t *driver)
>   	return 0;
>   }
>   
> -static int veth_receive(char *f_buffer_pc, int f_len_i, net_driver_t *driver)
> +static int veth_receive(char *f_buffer_pc, unsigned f_len_i, net_driver_t *driver)
>   {
>   	int packet = 0;
>   
> @@ -223,10 +223,14 @@ static int veth_xmit(char *f_buffer_pc, int f_len_i, net_driver_t *driver)
>   	return f_len_i;
>   }
>   
> -net_driver_t *libveth_open(char *mac_addr, int mac_len, char *reg, int reg_len)
> +net_driver_t *libveth_open(char *mac_addr, unsigned mac_len, char *reg, unsigned reg_len)
>   {
>   	net_driver_t *driver;
>   
> +	if (reg_len != sizeof(uint32_t)) {
> +		printf("vio reg must 1 cell long\n");
> +		return NULL;
> +	}
>   	driver = SLOF_alloc_mem(sizeof(*driver));
>   	if (!driver) {
>   		printf("Unable to allocate veth driver\n");
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/lib/libveth/veth.h b/lib/libveth/veth.h
index 23af0eab6211..6a1cb4cb5790 100644
--- a/lib/libveth/veth.h
+++ b/lib/libveth/veth.h
@@ -16,7 +16,7 @@ 
 #include <stdint.h>
 #include <netdriver.h>
 
-extern net_driver_t *libveth_open(char *mac_addr, int mac_len, char *reg, int reg_len);
+extern net_driver_t *libveth_open(char *mac_addr, unsigned mac_len, char *reg, unsigned reg_len);
 extern void libveth_close(net_driver_t *driver);
 extern int libveth_read(char *buf, int len, net_driver_t *driver);
 extern int libveth_write(char *buf, int len, net_driver_t *driver);
diff --git a/lib/libveth/veth.c b/lib/libveth/veth.c
index 748730854035..a8e19ba41764 100644
--- a/lib/libveth/veth.c
+++ b/lib/libveth/veth.c
@@ -164,7 +164,7 @@  static int veth_term(net_driver_t *driver)
 	return 0;
 }
 
-static int veth_receive(char *f_buffer_pc, int f_len_i, net_driver_t *driver)
+static int veth_receive(char *f_buffer_pc, unsigned f_len_i, net_driver_t *driver)
 {
 	int packet = 0;
 
@@ -223,10 +223,14 @@  static int veth_xmit(char *f_buffer_pc, int f_len_i, net_driver_t *driver)
 	return f_len_i;
 }
 
-net_driver_t *libveth_open(char *mac_addr, int mac_len, char *reg, int reg_len)
+net_driver_t *libveth_open(char *mac_addr, unsigned mac_len, char *reg, unsigned reg_len)
 {
 	net_driver_t *driver;
 
+	if (reg_len != sizeof(uint32_t)) {
+		printf("vio reg must 1 cell long\n");
+		return NULL;
+	}
 	driver = SLOF_alloc_mem(sizeof(*driver));
 	if (!driver) {
 		printf("Unable to allocate veth driver\n");