[PATCH 2/2] object.c: initialize automatic variable in lookup_object()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Initialize a "struct object obj*" variable to NULL explicitly and
return it instead of leaving it uninitialized until the "while"
loop.

There was no bug here, it's just less confusing when debugging if the
"obj" is either NULL or a valid object, not some random invalid
pointer.

See 0556a11a0df (git object hash cleanups, 2006-06-30) for the initial
implementation.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/object.c b/object.c
index 63896abf01..7fdca3ed1e 100644
--- a/object.c
+++ b/object.c
@@ -87,10 +87,10 @@ static void insert_obj_hash(struct object *obj, struct object **hash, unsigned i
 struct object *lookup_object(struct repository *r, const struct object_id *oid)
 {
 	unsigned int i, first;
-	struct object *obj;
+	struct object *obj = NULL;
 
 	if (!r->parsed_objects->obj_hash)
-		return NULL;
+		return obj;
 
 	first = i = hash_obj(oid, r->parsed_objects->obj_hash_size);
 	while ((obj = r->parsed_objects->obj_hash[i]) != NULL) {
-- 
2.31.1.584.gf4baedee75




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux