Uploaded image for project: 'Libmongocrypt'
  1. Libmongocrypt
  2. MONGOCRYPT-512

libmongocrypt has warnings with -Wsign-compare

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.9.0
    • Affects Version/s: None
    • Component/s: None
    • None

      Repro

      mkdir repro
      cd repro
      cmake -DCMAKE_C_FLAGS="-Werror -Wsign-compare" -GNinja ..
      

      Tested with GCC 12.2.1 but I think this will repro in any recent GCC or Clang.

      Errors:

      [11/397] Building C object CMakeFiles/mongocrypt.dir/src/mc-fle2-encryption-placeholder.c.o
      FAILED: CMakeFiles/mongocrypt.dir/src/mc-fle2-encryption-placeholder.c.o
      /usr/bin/cc -DBSON_STATIC -DKMS_MSG_STATIC -DMLIB_HAVE_STRINGS_H -DMLIB_USER -DMONGOCRYPT_LITTLE_ENDIAN -Dmongocrypt_EXPORTS -I/home/mark/src/libmongocrypt/kms-message/src -I/home/mark/src/libmongocrypt/src -I/home/mark/src/libmongocrypt/repro/src -I/home/mark/src/libmongocrypt/repro/_deps/embedded_mcd-src/src/libbson/src -I/home/mark/src/libmongocrypt/repro/_mongo-c-driver/src/libbson/src -I/home/mark/src/libmongocrypt/repro/_mongo-c-driver/src/libbson/src/bson -Werror -Wsign-compare -fPIC -Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=discarded-qualifiers -Werror=uninitialized -fPIC -std=gnu99 -MD -MT CMakeFiles/mongocrypt.dir/src/mc-fle2-encryption-placeholder.c.o -MF CMakeFiles/mongocrypt.dir/src/mc-fle2-encryption-placeholder.c.o.d -o CMakeFiles/mongocrypt.dir/src/mc-fle2-encryption-placeholder.c.o -c /home/mark/src/libmongocrypt/src/mc-fle2-encryption-placeholder.c
      /home/mark/src/libmongocrypt/src/mc-fle2-encryption-placeholder.c: In function ‘mc_validate_sparsity’:
      /home/mark/src/libmongocrypt/src/mc-fle2-encryption-placeholder.c:210:17: error: comparison of integer expressions of different signedness: ‘int64_t’ {aka ‘long int’} and ‘long unsigned int’ [-Werror=sign-compare]
        210 |    if (sparsity >= SIZE_MAX) {
            |                 ^~
      cc1: all warnings being treated as errors
      [15/397] Building C object CMakeFiles/mongocrypt.dir/src/crypto/libcrypto.c.o
      FAILED: CMakeFiles/mongocrypt.dir/src/crypto/libcrypto.c.o
      /usr/bin/cc -DBSON_STATIC -DKMS_MSG_STATIC -DMLIB_HAVE_STRINGS_H -DMLIB_USER -DMONGOCRYPT_LITTLE_ENDIAN -Dmongocrypt_EXPORTS -I/home/mark/src/libmongocrypt/kms-message/src -I/home/mark/src/libmongocrypt/src -I/home/mark/src/libmongocrypt/repro/src -I/home/mark/src/libmongocrypt/repro/_deps/embedded_mcd-src/src/libbson/src -I/home/mark/src/libmongocrypt/repro/_mongo-c-driver/src/libbson/src -I/home/mark/src/libmongocrypt/repro/_mongo-c-driver/src/libbson/src/bson -Werror -Wsign-compare -fPIC -Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=discarded-qualifiers -Werror=uninitialized -fPIC -std=gnu99 -MD -MT CMakeFiles/mongocrypt.dir/src/crypto/libcrypto.c.o -MF CMakeFiles/mongocrypt.dir/src/crypto/libcrypto.c.o.d -o CMakeFiles/mongocrypt.dir/src/crypto/libcrypto.c.o -c /home/mark/src/libmongocrypt/src/crypto/libcrypto.c
      In file included from /home/mark/src/libmongocrypt/repro/_deps/embedded_mcd-src/src/libbson/src/bson/bson-compat.h:35,
                       from /home/mark/src/libmongocrypt/repro/_deps/embedded_mcd-src/src/libbson/src/bson/bson.h:23,
                       from /home/mark/src/libmongocrypt/src/crypto/../mongocrypt-buffer-private.h:20,
                       from /home/mark/src/libmongocrypt/src/crypto/../mongocrypt-crypto-private.h:21,
                       from /home/mark/src/libmongocrypt/src/crypto/libcrypto.c:22:
      /home/mark/src/libmongocrypt/src/crypto/libcrypto.c: In function ‘_encrypt_with_cipher’:
      /home/mark/src/libmongocrypt/src/crypto/libcrypto.c:84:47: error: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Werror=sign-compare]
         84 |                 EVP_CIPHER_iv_length (cipher) == args.iv->len);
            |                                               ^~
      

            Assignee:
            roberto.sanchez@mongodb.com Roberto Sanchez
            Reporter:
            mark.benvenuto@mongodb.com Mark Benvenuto
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: