List for cgit developers and users
 help / color / mirror / Atom feed
* Typo introduced #2f50b47
@ 2024-08-03 21:52 Alexander Pickering
  2024-08-04  3:01 ` Kian Kasad
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Pickering @ 2024-08-03 21:52 UTC (permalink / raw)
  To: cgit


[-- Attachment #1.1: Type: text/plain, Size: 807 bytes --]

Hi all,

Thanks for cgit, it's great! I have cgit occasionally (re-)compiling on 
a Debian 11 system with gcc, today it errored in scan-tree.c on the 
master branch. My setup script is:

	git clone https://git.zx2c4.com/cgit
	cd cgit
	git submodule init
	git submodule update
	make
	make install


I got the error

	../scan-tree.c:57:65: error: parameter name omitted
    57 | ic int gitconfig_config(const char *key, const char *value,
		const struct config_context *, void *cb)

I think this line

	static int gitconfig_config(const char *key, const char *value, const 
struct config_context *, void *cb)

should be
	
	static int gitconfig_config(const char *key, const char *value, void *cb)

If I make this change, it compiles and seems to work as expected.

Best,
Alex

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

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

* Re: Typo introduced #2f50b47
  2024-08-03 21:52 Typo introduced #2f50b47 Alexander Pickering
@ 2024-08-04  3:01 ` Kian Kasad
  2024-08-04  3:18   ` [PATCH] Fix error caused by missing parameter name Kian Kasad
  0 siblings, 1 reply; 5+ messages in thread
From: Kian Kasad @ 2024-08-04  3:01 UTC (permalink / raw)
  To: cgit; +Cc: Alexander Pickering


> On Aug 3, 2024, at 14:52, Alexander Pickering <alex@cogarr.net> wrote:
> 
> ../scan-tree.c:57:65: error: parameter name omitted
>   57 | ic int gitconfig_config(const char *key, const char *value,
> const struct config_context *, void *cb)
> 
> I think this line
> 
> 	static int gitconfig_config(const char *key, const char *value, const struct config_context *, void *cb)
> 
> should be
> 
> 	static int gitconfig_config(const char *key, const char *value, void *cb)

I agree that that’s a mistake, but I disagree with your suggested change.

The gitconfig_config() function is passed as the first argument to the
git_config_from_file() function which is defined in git/config.c. That function
expects the first argument to be of type config_fn_t, which does have the
context argument. This is why it was added to gitconfig_config(). Therefore, the
proper solution is to just give that argument a name, as removing it completely
could cause further errors:

	static int gitconfig_config(const char *key, const char *value, const struct config_context *UNUSED, void *cb)

Git seems to use the name “UNUSED” which is why I have followed suit here.

-- 
Kian Kasad
kian@kasad.com <mailto:kian@kasad.com>
(925) 871-9823 <tel:+19258719823>

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

* [PATCH] Fix error caused by missing parameter name
  2024-08-04  3:01 ` Kian Kasad
@ 2024-08-04  3:18   ` Kian Kasad
  2024-08-04  6:17     ` Денис Пронин
  0 siblings, 1 reply; 5+ messages in thread
From: Kian Kasad @ 2024-08-04  3:18 UTC (permalink / raw)
  To: cgit; +Cc: Kian Kasad

This fixes an error which was introduced by
2f50b47c72cbc4270bbd12ae7f520486d5f42736. Git added a new argument to
config_fn_t, and it was added to gitconfig_config(), but not named. This
causes compile warnings/errors. This commit fixes that by naming the new
parameter.
---
 scan-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scan-tree.c b/scan-tree.c
index 84da86e..d4fecd8 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -54,7 +54,8 @@ static void scan_tree_repo_config(const char *name, const char *value)
 	config_fn(repo, name, value);
 }
 
-static int gitconfig_config(const char *key, const char *value, const struct config_context *, void *cb)
+static int gitconfig_config(const char *key, const char *value,
+		const struct config_context *UNUSED, void *cb)
 {
 	const char *name;
 
-- 
2.46.0


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

* Re: [PATCH] Fix error caused by missing parameter name
  2024-08-04  3:18   ` [PATCH] Fix error caused by missing parameter name Kian Kasad
@ 2024-08-04  6:17     ` Денис Пронин
  2024-08-04 18:43       ` [PATCH v2] " Kian Kasad
  0 siblings, 1 reply; 5+ messages in thread
From: Денис Пронин @ 2024-08-04  6:17 UTC (permalink / raw)
  To: Kian Kasad; +Cc: cgit

Hi,

Don't you like to use __attribute__((unused)) for marking a parameter 
when such a need comes up?

04.08.2024 06:18, Kian Kasad пишет:
> This fixes an error which was introduced by
> 2f50b47c72cbc4270bbd12ae7f520486d5f42736. Git added a new argument to
> config_fn_t, and it was added to gitconfig_config(), but not named. This
> causes compile warnings/errors. This commit fixes that by naming the new
> parameter.
> ---
>   scan-tree.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/scan-tree.c b/scan-tree.c
> index 84da86e..d4fecd8 100644
> --- a/scan-tree.c
> +++ b/scan-tree.c
> @@ -54,7 +54,8 @@ static void scan_tree_repo_config(const char *name, const char *value)
>   	config_fn(repo, name, value);
>   }
>   
> -static int gitconfig_config(const char *key, const char *value, const struct config_context *, void *cb)
> +static int gitconfig_config(const char *key, const char *value,
> +		const struct config_context *UNUSED, void *cb)
>   {
>   	const char *name;
>   

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

* [PATCH v2] Fix error caused by missing parameter name
  2024-08-04  6:17     ` Денис Пронин
@ 2024-08-04 18:43       ` Kian Kasad
  0 siblings, 0 replies; 5+ messages in thread
From: Kian Kasad @ 2024-08-04 18:43 UTC (permalink / raw)
  To: cgit; +Cc: dannftk, Kian Kasad

This fixes an error which was introduced by
2f50b47c72cbc4270bbd12ae7f520486d5f42736. Git added a new argument to
config_fn_t, and it was added to gitconfig_config(), but not named. This
causes compile warnings/errors. This commit fixes that by naming the new
parameter, and marking it unused.

---

The attribute used here is specific to GCC and Clang, but we're already
using non-standard features like the memrchr() function, so this seems
like it isn't a problem.

 scan-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scan-tree.c b/scan-tree.c
index 84da86e..8858b74 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -54,7 +54,8 @@ static void scan_tree_repo_config(const char *name, const char *value)
 	config_fn(repo, name, value);
 }
 
-static int gitconfig_config(const char *key, const char *value, const struct config_context *, void *cb)
+static int gitconfig_config(const char *key, const char *value,
+		const __attribute__((unused)) struct config_context *ctx, void *cb)
 {
 	const char *name;
 
-- 
2.46.0


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

end of thread, other threads:[~2024-08-04 18:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-03 21:52 Typo introduced #2f50b47 Alexander Pickering
2024-08-04  3:01 ` Kian Kasad
2024-08-04  3:18   ` [PATCH] Fix error caused by missing parameter name Kian Kasad
2024-08-04  6:17     ` Денис Пронин
2024-08-04 18:43       ` [PATCH v2] " Kian Kasad

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).