[PATCH] repository: fix a sparse 'using integer a NULL pointer' warning

Subsystems: the rest

STALE3267d

3 messages, 3 authors, 2017-08-22 · open the first message on its own page

[PATCH] repository: fix a sparse 'using integer a NULL pointer' warning

From: Ramsay Jones <hidden>
Date: 2017-08-21 15:48:51

Commit 67a9dfcc00 ("hash-algo: integrate hash algorithm support with
repo setup", 21-08-2017) added a 'const struct git_hash_algo *hash_algo'
field to the repository structure, without modifying the initializer
of the 'the_repo' variable. This does not actually introduce a bug,
since the '0' initializer for the 'ignore_env:1' bit-field is
interpreted as a NULL pointer (hence the warning), and the final field
(now with no initializer) receives a default '0'.

Signed-off-by: Ramsay Jones <redacted>
---

Hi Brian,

If you need to re-roll your 'bc/hash-algo' branch, could you please
squash this into the relevant patch.

Thanks!

ATB,
Ramsay Jones

 repository.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/repository.c b/repository.c
index 01af20dee..ceef73614 100644
--- a/repository.c
+++ b/repository.c
@@ -5,7 +5,7 @@
 
 /* The main repository */
 static struct repository the_repo = {
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, 0, 0
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, NULL, 0, 0
 };
 struct repository *the_repository = &the_repo;
 
-- 
2.14.0

Re: [PATCH] repository: fix a sparse 'using integer a NULL pointer' warning

From: brian m. carlson <hidden>
Date: 2017-08-22 02:11:35

On Mon, Aug 21, 2017 at 04:48:42PM +0100, Ramsay Jones wrote:
Commit 67a9dfcc00 ("hash-algo: integrate hash algorithm support with
repo setup", 21-08-2017) added a 'const struct git_hash_algo *hash_algo'
field to the repository structure, without modifying the initializer
of the 'the_repo' variable. This does not actually introduce a bug,
since the '0' initializer for the 'ignore_env:1' bit-field is
interpreted as a NULL pointer (hence the warning), and the final field
(now with no initializer) receives a default '0'.

Signed-off-by: Ramsay Jones <redacted>
---

Hi Brian,

If you need to re-roll your 'bc/hash-algo' branch, could you please
squash this into the relevant patch.
Of course, thanks.  I'll almost certainly be doing a reroll since it's
an RFC series and I expect to get more feedback on it.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204

Re: [PATCH] repository: fix a sparse 'using integer a NULL pointer' warning

From: René Scharfe <hidden>
Date: 2017-08-22 17:36:21

Am 21.08.2017 um 17:48 schrieb Ramsay Jones:
quoted hunk
Commit 67a9dfcc00 ("hash-algo: integrate hash algorithm support with
repo setup", 21-08-2017) added a 'const struct git_hash_algo *hash_algo'
field to the repository structure, without modifying the initializer
of the 'the_repo' variable. This does not actually introduce a bug,
since the '0' initializer for the 'ignore_env:1' bit-field is
interpreted as a NULL pointer (hence the warning), and the final field
(now with no initializer) receives a default '0'.

Signed-off-by: Ramsay Jones <redacted>
---

Hi Brian,

If you need to re-roll your 'bc/hash-algo' branch, could you please
squash this into the relevant patch.

Thanks!

ATB,
Ramsay Jones

  repository.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/repository.c b/repository.c
index 01af20dee..ceef73614 100644
--- a/repository.c
+++ b/repository.c
@@ -5,7 +5,7 @@
  
  /* The main repository */
  static struct repository the_repo = {
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, 0, 0
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &the_index, NULL, 0, 0
This line yells out "designated initializer" to me:

+	.index = &the_index
  };
  struct repository *the_repository = &the_repo;
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help