Skip to content

Conversation

@jesper-olsen
Copy link

Description of Change

Summary

This Pull Request addresses several compiler warnings found when compiling the repository with strict compiler flags (e.g., Clang 17.0.0 on macOS, which uses -Wall). These changes ensure better code quality, portability, and adherence to modern C standards without altering the functionality of the algorithms.

Specific Warnings Fixed

  1. Implicit Unsigned Literals (-Wimplicitly-unsigned-literal):
    • Fixed by adding the ULL suffix to large constants in decimal_to_any_base.c and hash_djb2.c.
  2. Double/Float Mismatch (-Wabsolute-value):
    • Changed fabsf to the double-precision function fabs in geometry/vectors_3d.c because the variable alpha is of type double.
  3. Const-Correctness (-Wincompatible-pointer-types-discards-qualifiers):
    • Applied an explicit cast (const int **) in the main function of modified_binary_search.c to match the function signature, resolving the const-discarding warning.
  4. Format Mismatch (-Wformat):
    • Corrected the format specifier for scanf in collatz.c to %llu to correctly read into a uint64_t.
    • Corrected the printf format specifier in shell_sort2.c from %.4g (double) to %.4lu (unsigned long) for printing clock_t differences.
  5. Misc:
    • Simplified array iteration initialization in prime_factoriziation.c (C99 style initialization inside the for loop).

Thank you for reviewing!

Checklist

  • Added description of change
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:

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.

1 participant