Re: [Maria-developers] MariaDB made be compiled by gcc 4.8.1
Hi, Sanja!
=== modified file 'storage/maria/ma_checksum.c' --- a/storage/maria/ma_checksum.c 2008-04-03 13:40:25 +0000 +++ b/storage/maria/ma_checksum.c 2013-10-22 07:56:05 +0000 @@ -58,7 +58,7 @@ ha_checksum _ma_checksum(MARIA_HA *info, length= _ma_calc_blob_length(blob_size_length, pos); if (length) { - memcpy((char*) &pos, pos + blob_size_length, sizeof(char*)); + memcpy((char*) &pos, pos + blob_size_length, (sizeof(char*))); Why? ma_checksum.c: In function '_ma_checksum': ma_checksum.c:61:60: error: argument to 'sizeof' in 'memcpy' call is the same pointer type 'char *' as the destination; expected 'char' or an explicit length [-Werror=sizeof-pointer-memaccess] memcpy((char*) &pos, pos + blob_size_length, sizeof(char*)); ^
shouldn't it be: memcpy((char**) &pos, pos + blob_size_length, sizeof(char*));
Sanja ^^^ That would be a better fix. The result looks more logical than with meaningless parentheses. Or, I suppose, you can try to drop the cast completely: memcpy(&pos, pos + blob_size_length, sizeof(pos));
BTW all other such fixes was done because this check.
Yes, I've figured it out. Regards, Sergei
24.10.2013 11:54, Sergei Golubchik пишет:
Hi, Sanja!
=== modified file 'storage/maria/ma_checksum.c' --- a/storage/maria/ma_checksum.c 2008-04-03 13:40:25 +0000 +++ b/storage/maria/ma_checksum.c 2013-10-22 07:56:05 +0000 @@ -58,7 +58,7 @@ ha_checksum _ma_checksum(MARIA_HA *info, length= _ma_calc_blob_length(blob_size_length, pos); if (length) { - memcpy((char*) &pos, pos + blob_size_length, sizeof(char*)); + memcpy((char*) &pos, pos + blob_size_length, (sizeof(char*))); Why? ma_checksum.c: In function '_ma_checksum': ma_checksum.c:61:60: error: argument to 'sizeof' in 'memcpy' call is the same pointer type 'char *' as the destination; expected 'char' or an explicit length [-Werror=sizeof-pointer-memaccess] memcpy((char*) &pos, pos + blob_size_length, sizeof(char*)); ^ shouldn't it be: memcpy((char**) &pos, pos + blob_size_length, sizeof(char*)); Sanja ^^^
That would be a better fix. The result looks more logical than with meaningless parentheses.
Or, I suppose, you can try to drop the cast completely:
memcpy(&pos, pos + blob_size_length, sizeof(pos));
Hehe, it was my first fix (remove casting). but then I thought that the casting was done for something and decided do not touch it. If you think that this way is better I'll do it. [skip]
Hi, Oleksandr! On Oct 24, Oleksandr Byelkin wrote:
Or, I suppose, you can try to drop the cast completely:
memcpy(&pos, pos + blob_size_length, sizeof(pos));
Hehe, it was my first fix (remove casting). but then I thought that the casting was done for something and decided do not touch it. If you think that this way is better I'll do it.
Yes, please do. And not only in this place, but in all similar cases too. Thanks! Regards, Sergei
participants (2)
-
Oleksandr Byelkin
-
Sergei Golubchik