git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [Outreachy] patch-ids: fix const correctness
@ 2025-10-13 16:53 Okhuomon Ajayi
  2025-10-13 17:12 ` Junio C Hamano
  0 siblings, 1 reply; 13+ messages in thread
From: Okhuomon Ajayi @ 2025-10-13 16:53 UTC (permalink / raw)
  To: git; +Cc: Okhuomon Ajayi

The `patch_id_neq()` function received a pointer to diff options via
`cmpfn_data` but cast it to a non-const type. This caused a const
correctness warning and could potentially allow unintended modification
of read-only data.

Fix this by casting to `const struct diff_options *` instead, removing
the outdated NEEDSWORK comment in the process.

Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
 patch-ids.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/patch-ids.c b/patch-ids.c
index a5683b462c..b6b808332f 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -41,8 +41,8 @@ static int patch_id_neq(const void *cmpfn_data,
 			const struct hashmap_entry *entry_or_key,
 			const void *keydata UNUSED)
 {
-	/* NEEDSWORK: const correctness? */
-	struct diff_options *opt = (void *)cmpfn_data;
+	
+	const struct diff_options *opt = (void *)cmpfn_data;
 	struct patch_id *a, *b;
 
 	a = container_of(eptr, struct patch_id, ent);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [PATCH] [Outreachy] patch-ids: fix const correctness
@ 2025-10-09 21:44 Okhuomon Ajayi
  2025-10-09 21:46 ` Kristoffer Haugsbakk
  2025-10-09 21:57 ` Okhuomon Ajayi
  0 siblings, 2 replies; 13+ messages in thread
From: Okhuomon Ajayi @ 2025-10-09 21:44 UTC (permalink / raw)
  To: git; +Cc: Okhuomon Ajayi

Fix const correctness warning in patch_id_neq() in patch-ids.c.
---
 patch-ids.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/patch-ids.c b/patch-ids.c
index a5683b462c..4a72c2cbe6 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -42,7 +42,7 @@ static int patch_id_neq(const void *cmpfn_data,
 			const void *keydata UNUSED)
 {
 	/* NEEDSWORK: const correctness? */
-	struct diff_options *opt = (void *)cmpfn_data;
+	const struct diff_options *opt = (void *)cmpfn_data;
 	struct patch_id *a, *b;
 
 	a = container_of(eptr, struct patch_id, ent);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-10-13 21:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-13 16:53 [PATCH] [Outreachy] patch-ids: fix const correctness Okhuomon Ajayi
2025-10-13 17:12 ` Junio C Hamano
2025-10-13 17:22   ` Okhuomon Ajayi
2025-10-13 17:29     ` Junio C Hamano
2025-10-13 18:14       ` Okhuomon Ajayi
2025-10-13 18:33         ` Junio C Hamano
2025-10-13 21:55           ` Okhuomon Ajayi
  -- strict thread matches above, loose matches on Subject: below --
2025-10-09 21:44 Okhuomon Ajayi
2025-10-09 21:46 ` Kristoffer Haugsbakk
2025-10-10  0:45   ` Junio C Hamano
2025-10-09 21:57 ` Okhuomon Ajayi
2025-10-09 23:49   ` Agatha Isabelle
2025-10-10  0:13     ` Okhuomon Ajayi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).