Skip to content

Commit 3965f44

Browse files
committed
merge-ort: remove undefined pointer comparisons
Signed-off-by: Phillip Wood <[email protected]>
1 parent d10be99 commit 3965f44

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

merge-ort.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "tree.h"
3838
#include "unpack-trees.h"
3939
#include "xdiff-interface.h"
40+
#include <stddef.h>
4041

4142
/*
4243
* We have many arrays of size 3. Whenever we have such an array, the
@@ -3949,13 +3950,14 @@ static void process_entry(struct merge_options *opt,
39493950
static void prefetch_for_content_merges(struct merge_options *opt,
39503951
struct string_list *plist)
39513952
{
3952-
struct string_list_item *e;
39533953
struct oid_array to_fetch = OID_ARRAY_INIT;
3954+
size_t i;
39543955

39553956
if (opt->repo != the_repository || !has_promisor_remote())
39563957
return;
39573958

3958-
for (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {
3959+
for (i = plist->nr; i; i--) {
3960+
struct string_list_item *e = &plist->items[i - 1];
39593961
/* char *path = e->string; */
39603962
struct conflict_info *ci = e->util;
39613963
int i;
@@ -4000,10 +4002,10 @@ static void process_entries(struct merge_options *opt,
40004002
struct hashmap_iter iter;
40014003
struct strmap_entry *e;
40024004
struct string_list plist = STRING_LIST_INIT_NODUP;
4003-
struct string_list_item *entry;
40044005
struct directory_versions dir_metadata = { STRING_LIST_INIT_NODUP,
40054006
STRING_LIST_INIT_NODUP,
40064007
NULL, 0 };
4008+
size_t i;
40074009

40084010
trace2_region_enter("merge", "process_entries setup", opt->repo);
40094011
if (strmap_empty(&opt->priv->paths)) {
@@ -4041,7 +4043,8 @@ static void process_entries(struct merge_options *opt,
40414043
*/
40424044
trace2_region_enter("merge", "processing", opt->repo);
40434045
prefetch_for_content_merges(opt, &plist);
4044-
for (entry = &plist.items[plist.nr-1]; entry >= plist.items; --entry) {
4046+
for (i = plist.nr; i; i--) {
4047+
struct string_list_item *entry = &plist.items[i - 1];
40454048
char *path = entry->string;
40464049
/*
40474050
* NOTE: mi may actually be a pointer to a conflict_info, but

0 commit comments

Comments
 (0)