diff mbox series

[4/9] block/vpc: Make vpc_checksum() take void *

Message ID 20201217162003.1102738-5-armbru@redhat.com
State New
Headers show
Series block/vpc: Clean up some buffer abuse | expand

Commit Message

Markus Armbruster Dec. 17, 2020, 4:19 p.m. UTC
Some of the next commits will checksum structs.  Change vpc_checksum()
to take void * instead of uint8_t, to save us pointless casts to
uint8_t *.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 block/vpc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Max Reitz Dec. 18, 2020, 10:54 a.m. UTC | #1
On 17.12.20 17:19, Markus Armbruster wrote:
> Some of the next commits will checksum structs.  Change vpc_checksum()
> to take void * instead of uint8_t, to save us pointless casts to
> uint8_t *.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   block/vpc.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/vpc.c b/block/vpc.c
> index 34186640ee..5af9837806 100644
> --- a/block/vpc.c
> +++ b/block/vpc.c
> @@ -172,8 +172,9 @@ static QemuOptsList vpc_runtime_opts = {
>   
>   static QemuOptsList vpc_create_opts;
>   
> -static uint32_t vpc_checksum(uint8_t *buf, size_t size)
> +static uint32_t vpc_checksum(void *p, size_t size)
>   {
> +    uint8_t *buf = p;
>       uint32_t res = 0;
>       int i;

Using this opportunity to add consts would be nice, but not necessary:

Reviewed-by: Max Reitz <mreitz@redhat.com>
Markus Armbruster Dec. 18, 2020, 1:54 p.m. UTC | #2
Max Reitz <mreitz@redhat.com> writes:

> On 17.12.20 17:19, Markus Armbruster wrote:
>> Some of the next commits will checksum structs.  Change vpc_checksum()
>> to take void * instead of uint8_t, to save us pointless casts to
>> uint8_t *.
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>   block/vpc.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>> diff --git a/block/vpc.c b/block/vpc.c
>> index 34186640ee..5af9837806 100644
>> --- a/block/vpc.c
>> +++ b/block/vpc.c
>> @@ -172,8 +172,9 @@ static QemuOptsList vpc_runtime_opts = {
>>     static QemuOptsList vpc_create_opts;
>>   -static uint32_t vpc_checksum(uint8_t *buf, size_t size)
>> +static uint32_t vpc_checksum(void *p, size_t size)
>>   {
>> +    uint8_t *buf = p;
>>       uint32_t res = 0;
>>       int i;
>
> Using this opportunity to add consts would be nice, but not necessary:

Didn't think of it, missed opportunity.  Not worth a respin all by
itself, I think.  I'm fine with the maintainer adding const.

> Reviewed-by: Max Reitz <mreitz@redhat.com>

Thanks!
diff mbox series

Patch

diff --git a/block/vpc.c b/block/vpc.c
index 34186640ee..5af9837806 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -172,8 +172,9 @@  static QemuOptsList vpc_runtime_opts = {
 
 static QemuOptsList vpc_create_opts;
 
-static uint32_t vpc_checksum(uint8_t *buf, size_t size)
+static uint32_t vpc_checksum(void *p, size_t size)
 {
+    uint8_t *buf = p;
     uint32_t res = 0;
     int i;