Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CONC-700] fix calloc errors as warnings when compiling with gcc-14.1.0 #247

Open
wants to merge 1 commit into
base: 3.4
Choose a base branch
from

Conversation

heitbaum
Copy link

@heitbaum heitbaum commented Jun 3, 2024

ref: https://jira.mariadb.org/browse/CONC-700

error: 'calloc' sizes specified with 'sizeof' in the earlier argument
and not in the later argument [-Werror=calloc-transposed-args]
note: earlier argument should specify number of elements, later size
of each element

fixes:

Executing (target): ninja 
[144/145] Building C object unittest/libmariadb/CMakeFiles/bulk1.dir/bulk1.c.o
FAILED: unittest/libmariadb/CMakeFiles/bulk1.dir/bulk1.c.o 
/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-gcc -DHAVE_OPENSSL -DHAVE_REMOTEIO=1 -DHAVE_TLS -DLIBMARIADB -DMARIADB_MACHINE_TYPE=\"x86_64\" -DMARIADB_SYSTEM_TYPE=\"Linux\" -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-connector-c-3.4.0/.x86_64-libreelec-linux-gnu/include -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-connector-c-3.4.0/plugins/auth -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-connector-c-3.4.0/include -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-connector-c-3.4.0/plugins/compress -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-connector-c-3.4.0/plugins/pvio -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-connector-c-3.4.0/unittest/mytap -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-connector-c-3.4.0/unittest/libmariadb -march=x86-64-v3 -Wall -pipe  -O2 -fomit-frame-pointer -DNDEBUG -Wunused -Wlogical-op -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement -Wno-undef -Wno-unknown-pragmas -Wno-stringop-truncation -Werror  -DDBUG_OFF -MD -MT unittest/libmariadb/CMakeFiles/bulk1.dir/bulk1.c.o -MF unittest/libmariadb/CMakeFiles/bulk1.dir/bulk1.c.o.d -o unittest/libmariadb/CMakeFiles/bulk1.dir/bulk1.c.o -c /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/mariadb-connector-c-3.4.0/unittest/libmariadb/bulk1.c
../unittest/libmariadb/bulk1.c: In function 'bulk_with_unit_result_insert':
../unittest/libmariadb/bulk1.c:1129:43: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
 1129 |   lengths= (unsigned long *)calloc(sizeof(long), TEST_ARRAY_SIZE);
      |                                           ^~~~
../unittest/libmariadb/bulk1.c:1129:43: note: earlier argument should specify number of elements, later size of each element
../unittest/libmariadb/bulk1.c: In function 'bulk_with_unit_result_delete':
../unittest/libmariadb/bulk1.c:1254:39: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
 1254 |   vals= (unsigned int *)calloc(sizeof(int), 5);
      |                                       ^~~
../unittest/libmariadb/bulk1.c:1254:39: note: earlier argument should specify number of elements, later size of each element
../unittest/libmariadb/bulk1.c: In function 'bulk_with_unit_result_update':
../unittest/libmariadb/bulk1.c:1362:39: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
 1362 |   vals= (unsigned int *)calloc(sizeof(int), 5);
      |                                       ^~~
../unittest/libmariadb/bulk1.c:1362:39: note: earlier argument should specify number of elements, later size of each element
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.

error: 'calloc' sizes specified with 'sizeof' in the earlier argument
  and not in the later argument [-Werror=calloc-transposed-args]
note: earlier argument should specify number of elements, later size
  of each element
@heitbaum heitbaum changed the title fix calloc errors as warnings when compiling with gcc-14.1.0 [CONC-700] fix calloc errors as warnings when compiling with gcc-14.1.0 Jun 3, 2024
@grooverdan
Copy link
Contributor

All except for the first hunk change, which I think is incorrect if you consider it bytes, have been merged into the last 3 commits on https://github.com/mariadb-corporation/mariadb-connector-c/commits/3.4/unittest/libmariadb/bulk1.c

@heitbaum
Copy link
Author

All except for the first hunk change, which I think is incorrect if you consider it bytes, have been merged into the last 3 commits on https://github.com/mariadb-corporation/mariadb-connector-c/commits/3.4/unittest/libmariadb/bulk1.c

Thanks...

  buffer[0]= calloc(1, 7);
  strcpy (buffer[0], "\xC3\x82\xC3\x83\xC3\x84\x00");

With regard to the first one - it works either way, but I believe the intention was:
buffer[0]= calloc(7, sizeof(char)); given the use of strcpy the terminator is "0x00" and that buffer[0] is a char *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants