]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ps/build-sign-compare'
authorJunio C Hamano <gitster@pobox.com>
Mon, 23 Dec 2024 17:32:10 +0000 (09:32 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Dec 2024 17:32:11 +0000 (09:32 -0800)
Start working to make the codebase buildable with -Wsign-compare.

* ps/build-sign-compare:
  t/helper: don't depend on implicit wraparound
  scalar: address -Wsign-compare warnings
  builtin/patch-id: fix type of `get_one_patchid()`
  builtin/blame: fix type of `length` variable when emitting object ID
  gpg-interface: address -Wsign-comparison warnings
  daemon: fix type of `max_connections`
  daemon: fix loops that have mismatching integer types
  global: trivial conversions to fix `-Wsign-compare` warnings
  pkt-line: fix -Wsign-compare warning on 32 bit platform
  csum-file: fix -Wsign-compare warning on 32-bit platform
  diff.h: fix index used to loop through unsigned integer
  config.mak.dev: drop `-Wno-sign-compare`
  global: mark code units that generate warnings with `-Wsign-compare`
  compat/win32: fix -Wsign-compare warning in "wWinMain()"
  compat/regex: explicitly ignore "-Wsign-compare" warnings
  git-compat-util: introduce macros to disable "-Wsign-compare" warnings

50 files changed:
1  2 
advice.c
attr.c
builtin/branch.c
builtin/cat-file.c
builtin/checkout.c
builtin/describe.c
builtin/fast-import.c
builtin/fetch.c
builtin/gc.c
builtin/index-pack.c
builtin/log.c
builtin/merge.c
builtin/pack-objects.c
builtin/pack-redundant.c
builtin/remote.c
builtin/repack.c
builtin/rev-list.c
builtin/tag.c
builtin/worktree.c
bundle-uri.c
bundle.c
commit-graph.c
commit.c
config.c
daemon.c
diff.c
fetch-pack.c
http.c
list-objects.c
midx-write.c
midx.c
object-name.c
oss-fuzz/fuzz-parse-attr-line.c
pack-bitmap.c
packfile.c
path.c
refs.c
refs/files-backend.c
reftable/system.h
remote.c
revision.c
setup.c
strvec.c
t/unit-tests/lib-reftable.c
t/unit-tests/t-reftable-readwrite.c
t/unit-tests/t-reftable-stack.c
tag.c
transport.c
version.c
worktree.c

diff --cc advice.c
Simple merge
diff --cc attr.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc builtin/fetch.c
Simple merge
diff --cc builtin/gc.c
Simple merge
Simple merge
diff --cc builtin/log.c
Simple merge
diff --cc builtin/merge.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc builtin/tag.c
Simple merge
Simple merge
diff --cc bundle-uri.c
Simple merge
diff --cc bundle.c
Simple merge
diff --cc commit-graph.c
Simple merge
diff --cc commit.c
Simple merge
diff --cc config.c
Simple merge
diff --cc daemon.c
Simple merge
diff --cc diff.c
Simple merge
diff --cc fetch-pack.c
Simple merge
diff --cc http.c
Simple merge
diff --cc list-objects.c
Simple merge
diff --cc midx-write.c
index bcd1d50eb0f5c292c904a38f13279b1ebec9c855,f1a6f83baee834ab9b40ee2e566b515d06cbb4c5..0066594fa6310b37903972e150c7cd1d7e232c38
@@@ -1,3 -1,6 +1,5 @@@
 -#define USE_THE_REPOSITORY_VARIABLE
+ #define DISABLE_SIGN_COMPARE_WARNINGS
  #include "git-compat-util.h"
  #include "abspath.h"
  #include "config.h"
diff --cc midx.c
index e0eae1c25ec91f7db5670ff9bacdf0e195c35795,504e03327ab0dd135e4772ec8b9de4bdd77da3f5..f8a75cafd4efeabd273268ba04cddefaa434e5b2
--- 1/midx.c
--- 2/midx.c
+++ b/midx.c
@@@ -1,3 -1,6 +1,5 @@@
 -#define USE_THE_REPOSITORY_VARIABLE
+ #define DISABLE_SIGN_COMPARE_WARNINGS
  #include "git-compat-util.h"
  #include "config.h"
  #include "dir.h"
diff --cc object-name.c
Simple merge
index 45a4c4e53cf41f3e84cf69e37e2a82d71c19d661,0000000000000000000000000000000000000000..e0e4bc635874a47e0ba1d04b8d92d85d42d41dc1
mode 100644,000000..100644
--- /dev/null
@@@ -1,39 -1,0 +1,41 @@@
++#define DISABLE_SIGN_COMPARE_WARNINGS
++
 +#include "git-compat-util.h"
 +#include <stddef.h>
 +#include <stdlib.h>
 +#include <stdint.h>
 +#include <string.h>
 +#include "attr.h"
 +
 +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
 +
 +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
 +{
 +      struct match_attr *res;
 +      char *buf;
 +
 +      buf = malloc(size + 1);
 +      if (!buf)
 +              return 0;
 +
 +      memcpy(buf, data, size);
 +      buf[size] = 0;
 +
 +      res = parse_attr_line(buf, "dummy", 0, 0);
 +
 +      if (res) {
 +              int j;
 +              for (j = 0; j < res->num_attr; j++) {
 +                      const char *setto = res->state[j].setto;
 +                      if (ATTR_TRUE(setto) || ATTR_FALSE(setto) ||
 +                              ATTR_UNSET(setto))
 +                              ;
 +                      else
 +                              free((char *)setto);
 +              }
 +              free(res);
 +      }
 +      free(buf);
 +
 +      return 0;
 +}
diff --cc pack-bitmap.c
index 7aa2410d9b0b5bfa68271fc40fe5d8472b4ed320,bbcf7e9401e43bbd7df1e764c96c62b9aa47ec2f..bceb6da042772df7afa741bafe7e4893473cbca8
@@@ -1,3 -1,6 +1,5 @@@
 -#define USE_THE_REPOSITORY_VARIABLE
+ #define DISABLE_SIGN_COMPARE_WARNINGS
  #include "git-compat-util.h"
  #include "commit.h"
  #include "gettext.h"
diff --cc packfile.c
index 9c4bd81a8c7c11f645a9afe94370e05d07c3063d,f38c207fb6b15ea52440c850d9dee103f5dbd940..cc7ab6403ae5fd5bc7bd09a56eae9f147a8ce727
@@@ -1,3 -1,5 +1,4 @@@
 -#define USE_THE_REPOSITORY_VARIABLE
+ #define DISABLE_SIGN_COMPARE_WARNINGS
  
  #include "git-compat-util.h"
  #include "environment.h"
diff --cc path.c
Simple merge
diff --cc refs.c
Simple merge
Simple merge
index 7d5f803eeb1bdeaec475c95c85e5966859542108,d3b8a55f4be3c5ca6e0278cf4334e45172a6be03..5274eca1d05b18bdadef9f991ff79fa83f3363e4
@@@ -11,91 -11,14 +11,93 @@@ https://developers.google.com/open-sour
  
  /* This header glues the reftable library to the rest of Git */
  
+ #define DISABLE_SIGN_COMPARE_WARNINGS
  #include "git-compat-util.h"
 -#include "lockfile.h"
 -#include "tempfile.h"
 -#include "hash.h" /* hash ID, sizes.*/
 -#include "dir.h" /* remove_dir_recursively, for tests.*/
  
 -int hash_size(uint32_t id);
 +/*
 + * An implementation-specific temporary file. By making this specific to the
 + * implementation it becomes possible to tie temporary files into any kind of
 + * signal or atexit handlers for cleanup on abnormal situations.
 + */
 +struct reftable_tmpfile {
 +      const char *path;
 +      int fd;
 +      void *priv;
 +};
 +#define REFTABLE_TMPFILE_INIT ((struct reftable_tmpfile) { .fd = -1, })
 +
 +/*
 + * Create a temporary file from a pattern similar to how mkstemp(3p) would.
 + * The `pattern` shall not be modified. On success, the structure at `out` has
 + * been initialized such that it is ready for use. Returns 0 on success, a
 + * reftable error code on error.
 + */
 +int tmpfile_from_pattern(struct reftable_tmpfile *out, const char *pattern);
 +
 +/*
 + * Close the temporary file's file descriptor without removing the file itself.
 + * This is a no-op in case the file has already been closed beforehand. Returns
 + * 0 on success, a reftable error code on error.
 + */
 +int tmpfile_close(struct reftable_tmpfile *t);
 +
 +/*
 + * Close the temporary file and delete it. This is a no-op in case the file has
 + * already been deleted or renamed beforehand. Returns 0 on success, a reftable
 + * error code on error.
 + */
 +int tmpfile_delete(struct reftable_tmpfile *t);
 +
 +/*
 + * Rename the temporary file to the provided path. The temporary file must be
 + * active. Return 0 on success, a reftable error code on error. Deactivates the
 + * temporary file.
 + */
 +int tmpfile_rename(struct reftable_tmpfile *t, const char *path);
 +
 +/*
 + * An implementation-specific file lock. Same as with `reftable_tmpfile`,
 + * making this specific to the implementation makes it possible to tie this
 + * into signal or atexit handlers such that we know to clean up stale locks on
 + * abnormal exits.
 + */
 +struct reftable_flock {
 +      const char *path;
 +      int fd;
 +      void *priv;
 +};
 +#define REFTABLE_FLOCK_INIT ((struct reftable_flock){ .fd = -1, })
 +
 +/*
 + * Acquire the lock for the given target path by exclusively creating a file
 + * with ".lock" appended to it. If that lock exists, we wait up to `timeout_ms`
 + * to acquire the lock. If `timeout_ms` is 0 we don't wait, if it is negative
 + * we block indefinitely.
 + *
 + * Retrun 0 on success, a reftable error code on error.
 + */
 +int flock_acquire(struct reftable_flock *l, const char *target_path,
 +                long timeout_ms);
 +
 +/*
 + * Close the lockfile's file descriptor without removing the lock itself. This
 + * is a no-op in case the lockfile has already been closed beforehand. Returns
 + * 0 on success, a reftable error code on error.
 + */
 +int flock_close(struct reftable_flock *l);
 +
 +/*
 + * Release the lock by unlinking the lockfile. This is a no-op in case the
 + * lockfile has already been released or committed beforehand. Returns 0 on
 + * success, a reftable error code on error.
 + */
 +int flock_release(struct reftable_flock *l);
 +
 +/*
 + * Commit the lock by renaming the lockfile into place. Returns 0 on success, a
 + * reftable error code on error.
 + */
 +int flock_commit(struct reftable_flock *l);
  
  #endif
diff --cc remote.c
Simple merge
diff --cc revision.c
Simple merge
diff --cc setup.c
Simple merge
diff --cc strvec.c
Simple merge
Simple merge
Simple merge
index e208e156f0ba86b40ef4b46db80b6014d8ca6ef8,4377c0af1b8fbd174bd6d25c693954244c31f802..aeec195b2b1014445d71c5db39a9795017fd8ff2
@@@ -6,9 -6,10 +6,11 @@@ license that can be found in the LICENS
  https://developers.google.com/open-source/licenses/bsd
  */
  
+ #define DISABLE_SIGN_COMPARE_WARNINGS
  #include "test-lib.h"
  #include "lib-reftable.h"
 +#include "dir.h"
  #include "reftable/merged.h"
  #include "reftable/reader.h"
  #include "reftable/reftable-error.h"
diff --cc tag.c
Simple merge
diff --cc transport.c
Simple merge
diff --cc version.c
Simple merge
diff --cc worktree.c
Simple merge