Skip to content
Snippets Groups Projects

vlc_common: replace last mul/add overflow usage with stdckdint.h

Closed Thomas Guillem requested to merge tguillem/vlc:vlc-common-overflow into master
2 unresolved threads

Maybe vlc_alloc should be moved from vlc_common.h to avoid that extra include.

Cc. @robUx4 @Courmisch is it breaking some cpp versions/msvc ?

Edited by Thomas Guillem

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
50 50 #include <stdio.h>
51 51 #include <inttypes.h>
52 52 #include <stddef.h>
53
54 #ifndef __cplusplus
55 # include <stdbool.h>
56 #endif
53 #include <stdbool.h>
54 #include <stdckdint.h>
  • If it's included here then it's not really needed in any modules.

    Also the log is weird as the lines you change don't match

    In file included from ../../include/vlc_common.h:56,
                     from ../../src/test/list_cpp.cpp:28:
    ../../include/vlc_common.h: In function ‘void* vlc_alloc(size_t, size_t)’:
    ../../include/vlc_common.h:925:12: error: ‘_Bool’ was not declared in this scope
      925 |     return ckd_mul(&size, count, size) ? NULL : malloc(size);

    _Bool is only used if the compiler is neither GCC or Clang in stdckdint.h. If an included is needed it should be done there (or the code modified there).

  • Author Maintainer

    If it's included here then it's not really needed in any modules.

    But this might change, we may want to move vlc_alloc helpers out of vlc_common.h.

    _Bool is only used if the compiler is neither GCC or Clang in stdckdint.h. If an included is needed it should be done there (or the code modified there).

    You mean, include <stdbool.h> from cpp before including <stdckdint.h> ?

  • No, the C++ issues of <stdckdint.h> should be handled in <stdckdint.h>, not in vlc_common.h.

  • Author Maintainer

    stdckdint.h is a system header and can't be modified (cpp is not using our compat code).

  • It's not a "system" header but a header from the toolchain. So it should be compatible with itself. You don't need any hack in that case. It's only needed in our version.

  • Author Maintainer

    So, how to fix properly for cpp ?

  • --- a/compat/stdckdint/stdckdint.h
    +++ b/compat/stdckdint/stdckdint.h
    @@ -25,6 +25,9 @@
     #  define ckd_mul(r, a, b) __builtin_mul_overflow(a, b, r)
     # else
     #  include <limits.h>
    +#  ifdef __cplusplus
    +#   include <stdbool.h> // _Bool
    +#  endif
     
     #  define __ckd_unsigned(suffix, type, MAX) \
     static inline _Bool __ckd_add_##suffix(type *r, type a, type b) \
  • Please register or sign in to reply
  • Please register or sign in to reply
    Loading