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

Clean up '-Wall' warnings from GCC #6

Open
bbassett-tibco opened this issue Sep 21, 2023 · 0 comments
Open

Clean up '-Wall' warnings from GCC #6

bbassett-tibco opened this issue Sep 21, 2023 · 0 comments

Comments

@bbassett-tibco
Copy link
Collaborator

When building with -Wall using current versions of GCC (for example, when building spotfiresoftware/spotfire-python using GCC 10.2.1 from the python:3.11 Docker image), the SBDF code emits a number of warnings. Clean up these warnings to reduce the number of warnings emitted when including the sources in another build (where we don't control the compiler flags added).

  • -Wparentheses: There are two forms of this warning (the former is the most common warning encountered):
src/columnmetadata.c: In function ‘sbdf_cm_get_type’:
src/columnmetadata.c:56:6: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   56 |  if (error = sbdf_md_get(SBDF_COLUMNMETADATA_DATATYPE, inp, &obj))
      |      ^~~~~
src/columnmetadata.c:61:103: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   61 |  if (obj->type.id != SBDF_BINARYTYPEID || obj->count != 1 || sbdf_ba_get_len(*(void**)obj->data) != 1 && sbdf_ba_get_len(*(void**)obj->data) != 3)
      |                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • -Wunused-function:
At top level:
src/internals.c:18:12: warning: ‘get_packed_digits_size’ defined but not used [-Wunused-function]
   18 | static int get_packed_digits_size(int digits)
      |            ^~~~~~~~~~~~~~~~~~~~~~
  • -Wsign-compare:
src/object.c: In function ‘sbdf_write_objects’:
src/object.c:399:39: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
  399 |       if (fwrite(*data, 1, length, f) != length)
      |                                       ^~
src/object.c: In function ‘sbdf_obj_copy’:
src/object.c:486:37: warning: operand of ‘?:’ changes signedness from ‘int’ to ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare]
  486 |  elem_size = is_array?sizeof(void*):sbdf_get_unpacked_size(t->type);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • -Wincompatible-pointer-types:
src/tablemetadata.c: In function ‘sbdf_tm_write’:
src/tablemetadata.c:583:64: warning: passing argument 4 of ‘qsort’ from incompatible pointer type [-Wincompatible-pointer-types]
  583 |  qsort((void*)array, array_size, sizeof(struct metadata_sort), compare_metadata_sort_by_name);
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                |
      |                                                                int (*)(const struct metadata_sort *, const struct metadata_sort *)
In file included from vendor/sbdf-c/src/tablemetadata.c:8:
/usr/include/stdlib.h:831:20: note: expected ‘__compar_fn_t’ {aka ‘int (*)(const void *, const void *)’} but argument is of type ‘int (*)(const struct metadata_sort *, const struct metadata_sort *)’
  831 |      __compar_fn_t __compar) __nonnull ((1, 4));
      |      ~~~~~~~~~~~~~~^~~~~~~~
  • -Wunused-but-set-variable:
src/valuearray.c: In function ‘sbdf_va_create_rle’:
src/valuearray.c:112:7: warning: variable ‘is_string’ set but not used [-Wunused-but-set-variable]
  112 |   int is_string;
      |       ^~~~~~~~~
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

No branches or pull requests

1 participant