mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
fsck: drop unused parameter from traverse_one_object()
Also add comments to seemingly unsafe pointer dereferences, that are all safe. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
d2d434beeb
commit
a1cdc25172
|
@ -74,7 +74,13 @@ static int mark_object(struct object *obj, int type, void *data)
|
||||||
{
|
{
|
||||||
struct object *parent = data;
|
struct object *parent = data;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The only case data is NULL or type is OBJ_ANY is when
|
||||||
|
* mark_object_reachable() calls us. All the callers of
|
||||||
|
* that function has non-NULL obj hence ...
|
||||||
|
*/
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
|
/* ... these references to parent->fld are safe here */
|
||||||
printf("broken link from %7s %s\n",
|
printf("broken link from %7s %s\n",
|
||||||
typename(parent->type), sha1_to_hex(parent->sha1));
|
typename(parent->type), sha1_to_hex(parent->sha1));
|
||||||
printf("broken link from %7s %s\n",
|
printf("broken link from %7s %s\n",
|
||||||
|
@ -84,6 +90,7 @@ static int mark_object(struct object *obj, int type, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != OBJ_ANY && obj->type != type)
|
if (type != OBJ_ANY && obj->type != type)
|
||||||
|
/* ... and the reference to parent is safe here */
|
||||||
objerror(parent, "wrong object type in link");
|
objerror(parent, "wrong object type in link");
|
||||||
|
|
||||||
if (obj->flags & REACHABLE)
|
if (obj->flags & REACHABLE)
|
||||||
|
@ -109,7 +116,7 @@ static void mark_object_reachable(struct object *obj)
|
||||||
mark_object(obj, OBJ_ANY, NULL);
|
mark_object(obj, OBJ_ANY, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int traverse_one_object(struct object *obj, struct object *parent)
|
static int traverse_one_object(struct object *obj)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
struct tree *tree = NULL;
|
struct tree *tree = NULL;
|
||||||
|
@ -138,7 +145,7 @@ static int traverse_reachable(void)
|
||||||
entry = pending.objects + --pending.nr;
|
entry = pending.objects + --pending.nr;
|
||||||
obj = entry->item;
|
obj = entry->item;
|
||||||
parent = (struct object *) entry->name;
|
parent = (struct object *) entry->name;
|
||||||
result |= traverse_one_object(obj, parent);
|
result |= traverse_one_object(obj);
|
||||||
}
|
}
|
||||||
return !!result;
|
return !!result;
|
||||||
}
|
}
|
||||||
|
@ -556,8 +563,8 @@ static int fsck_cache_tree(struct cache_tree *it)
|
||||||
sha1_to_hex(it->sha1));
|
sha1_to_hex(it->sha1));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
mark_object_reachable(obj);
|
|
||||||
obj->used = 1;
|
obj->used = 1;
|
||||||
|
mark_object_reachable(obj);
|
||||||
if (obj->type != OBJ_TREE)
|
if (obj->type != OBJ_TREE)
|
||||||
err |= objerror(obj, "non-tree in cache-tree");
|
err |= objerror(obj, "non-tree in cache-tree");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue