Re: [PATCH] contrib/git-credential-gnome-keyring.c: small stylistic cleanups

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] contrib/git-credential-gnome-keyring.c: small stylistic cleanups

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:59:25

John Szakmeister [off-list ref] writes:
quoted hunk
Signed-off-by: John Szakmeister <redacted>
---
The gnome-keyring credential backend had a number of coding style
violations.  I believe this fixes all of them.

 .../gnome-keyring/git-credential-gnome-keyring.c   | 55 ++++++++++------------
 1 file changed, 25 insertions(+), 30 deletions(-)
diff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
index 635c96b..1613404 100644
--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
@@ -95,9 +95,9 @@ static const char* gnome_keyring_result_to_message(GnomeKeyringResult result)
 
 static void gnome_keyring_done_cb(GnomeKeyringResult result, gpointer user_data)
 {
-	gpointer *data = (gpointer*) user_data;
-	int *done = (int*) data[0];
-	GnomeKeyringResult *r = (GnomeKeyringResult*) data[1];
+	gpointer *data = (gpointer *) user_data;
+	int *done = (int *) data[0];
+	GnomeKeyringResult *r = (GnomeKeyringResult *) data[1];
I thought we cast without SP after the (typename), i.e.

	gpointer *data = (gpointer *)user_data;

It could be argued that a cast that turns a "void *" to a pointer to
another type can go, as Felipe noted, but I think that is better
done in a separate patch, perhaps as a follow-up to this "small
stylistic clean-ups".

I said "it could be argued" above, because I am on the fence on that
change.  If this were not using a type "gpointer", whose point is to
hide what the actual implementation of that type is, but a plain
vanilla "void *", then I would not have any doubt.  But it feels
wrong to look behind that deliberate "gpointer" abstraction and take
advantage of the knowledge that it happens to be implemented as
"void *" (and if we do not start from that knowledge, losing the
cast is a wrong change).

So...

Re: [PATCH] contrib/git-credential-gnome-keyring.c: small stylistic cleanups

From: John Szakmeister <hidden>
Date: 2016-06-15 22:59:26

On Mon, Dec 9, 2013 at 1:06 PM, Junio C Hamano [off-list ref] wrote:
[snip]
I thought we cast without SP after the (typename), i.e.

        gpointer *data = (gpointer *)user_data;
I've found a mixture of both in the code base, and the
CodingGuidelines doesn't say either way.  I'm happy to switch the file
to no SP after the typename if that's the project preference.
It could be argued that a cast that turns a "void *" to a pointer to
another type can go, as Felipe noted, but I think that is better
done in a separate patch, perhaps as a follow-up to this "small
stylistic clean-ups".

I said "it could be argued" above, because I am on the fence on that
change.  If this were not using a type "gpointer", whose point is to
hide what the actual implementation of that type is, but a plain
vanilla "void *", then I would not have any doubt.  But it feels
wrong to look behind that deliberate "gpointer" abstraction and take
advantage of the knowledge that it happens to be implemented as
"void *" (and if we do not start from that knowledge, losing the
cast is a wrong change).
To be honest, I'm on the fence myself.  Let's just leave the original
patch queued, and if the no SP is preferable, I can do that as a
separate patch.

-John

PS  Sorry about the repeat message Junio.  I forgot to CC the list.

Re: [PATCH] contrib/git-credential-gnome-keyring.c: small stylistic cleanups

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:59:27

John Szakmeister [off-list ref] writes:
On Mon, Dec 9, 2013 at 1:06 PM, Junio C Hamano [off-list ref] wrote:
[snip]
quoted
I thought we cast without SP after the (typename), i.e.

        gpointer *data = (gpointer *)user_data;
I've found a mixture of both in the code base, and the
CodingGuidelines doesn't say either way.  I'm happy to switch the file
to no SP after the typename if that's the project preference.
Somewhat arbitrary and unscientific, but between

    git grep -e '[^f]([a-z_ ]* \*)[^ ]' -- \*.c | wc -l
    422
    $ git grep -e '[^f]([a-z_ ]* \*) ' -- \*.c | wc -l
    233

I see that we favor "(struct blah *)apointer" over "(int *)
apointer".  Many hits in the latter grep come from compat/
that are borrowed pieces of code we tend not to style-fix.

The leading [^f] is crudely excludes "sizeof(typename *)"; it does
not change the resulting picture in a major way, though.

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help