Skip to content

Commit a736764

Browse files
committed
Merge branch 'jk/clang-pedantic'
A few unportable C construct have been spotted by clang compiler and have been fixed. * jk/clang-pedantic: bswap: add NO_UNALIGNED_LOADS define avoid shifting signed integers 31 bits
2 parents 63aeeba + a0df2e5 commit a736764

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ static void prepare_shallow_update(struct command *commands,
16181618
continue;
16191619
si->need_reachability_test[i]++;
16201620
for (k = 0; k < 32; k++)
1621-
if (si->used_shallow[i][j] & (1 << k))
1621+
if (si->used_shallow[i][j] & (1U << k))
16221622
si->shallow_ref[j * 32 + k]++;
16231623
}
16241624

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ struct cache_entry {
215215
#define CE_INTENT_TO_ADD (1 << 29)
216216
#define CE_SKIP_WORKTREE (1 << 30)
217217
/* CE_EXTENDED2 is for future extension */
218-
#define CE_EXTENDED2 (1 << 31)
218+
#define CE_EXTENDED2 (1U << 31)
219219

220220
#define CE_EXTENDED_FLAGS (CE_INTENT_TO_ADD | CE_SKIP_WORKTREE)
221221

compat/bswap.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ static inline uint64_t git_bswap64(uint64_t x)
149149
* and is faster on architectures with memory alignment issues.
150150
*/
151151

152-
#if defined(__i386__) || defined(__x86_64__) || \
152+
#if !defined(NO_UNALIGNED_LOADS) && ( \
153+
defined(__i386__) || defined(__x86_64__) || \
153154
defined(_M_IX86) || defined(_M_X64) || \
154155
defined(__ppc__) || defined(__ppc64__) || \
155156
defined(__powerpc__) || defined(__powerpc64__) || \
156-
defined(__s390__) || defined(__s390x__)
157+
defined(__s390__) || defined(__s390x__))
157158

158159
#define get_be16(p) ntohs(*(unsigned short *)(p))
159160
#define get_be32(p) ntohl(*(unsigned int *)(p))

diff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)
9191
#define DIFF_OPT_DIRSTAT_BY_LINE (1 << 28)
9292
#define DIFF_OPT_FUNCCONTEXT (1 << 29)
9393
#define DIFF_OPT_PICKAXE_IGNORE_CASE (1 << 30)
94-
#define DIFF_OPT_DEFAULT_FOLLOW_RENAMES (1 << 31)
94+
#define DIFF_OPT_DEFAULT_FOLLOW_RENAMES (1U << 31)
9595

9696
#define DIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
9797
#define DIFF_OPT_TOUCHED(opts, flag) ((opts)->touched_flags & DIFF_OPT_##flag)

0 commit comments

Comments
 (0)