threads / patch / 35463

patchcontrib/git-credential-gnome-keyring.c: small stylistic cleanups

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

## tl;dr

8 messages between Dec 3, 2013 and Dec 13, 2013. Diffs are folded; open one to read it.

replies: 7people: 3as markdown or json

John Szakmeister· Dec 3, 2013, 10:32 UTC · lore
Signed-off-by: John Szakmeister <john@szakmeister.net>
---
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(-)
Show changes to contrib/credential/gnome-keyring/git-credential-gnome-keyring.c +25 −30
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];
 
 	*r = result;
 	*done = 1;
@@ -132,27 +132,25 @@ static GnomeKeyringResult gnome_keyring_item_delete_sync(const char *keyring, gu
  */
 struct credential
 {
-	char          *protocol;
-	char          *host;
+	char *protocol;
+	char *host;
 	unsigned short port;
-	char          *path;
-	char          *username;
-	char          *password;
+	char *path;
+	char *username;
+	char *password;
 };
 
-#define CREDENTIAL_INIT \
-  { NULL,NULL,0,NULL,NULL,NULL }
+#define CREDENTIAL_INIT { NULL, NULL, 0, NULL, NULL, NULL }
 
-typedef int (*credential_op_cb)(struct credential*);
+typedef int (*credential_op_cb)(struct credential *);
 
 struct credential_operation
 {
-	char             *name;
+	char *name;
 	credential_op_cb op;
 };
 
-#define CREDENTIAL_OP_END \
-  { NULL,NULL }
+#define CREDENTIAL_OP_END { NULL, NULL }
 
 /* ----------------- GNOME Keyring functions ----------------- */
 
@@ -221,7 +219,7 @@ static int keyring_get(struct credential *c)
 static int keyring_store(struct credential *c)
 {
 	guint32 item_id;
-	char  *object = NULL;
+	char *object = NULL;
 	GnomeKeyringResult result;
 
 	/*
@@ -262,7 +260,7 @@ static int keyring_store(struct credential *c)
 
 static int keyring_erase(struct credential *c)
 {
-	char  *object = NULL;
+	char *object = NULL;
 	GList *entries;
 	GnomeKeyringNetworkPasswordData *password_data;
 	GnomeKeyringResult result;
@@ -298,8 +296,7 @@ static int keyring_erase(struct credential *c)
 	if (result == GNOME_KEYRING_RESULT_CANCELLED)
 		return EXIT_SUCCESS;
 
-	if (result != GNOME_KEYRING_RESULT_OK)
-	{
+	if (result != GNOME_KEYRING_RESULT_OK) {
 		g_critical("%s", gnome_keyring_result_to_message(result));
 		return EXIT_FAILURE;
 	}
@@ -312,8 +309,7 @@ static int keyring_erase(struct credential *c)
 
 	gnome_keyring_network_password_list_free(entries);
 
-	if (result != GNOME_KEYRING_RESULT_OK)
-	{
+	if (result != GNOME_KEYRING_RESULT_OK) {
 		g_critical("%s", gnome_keyring_result_to_message(result));
 		return EXIT_FAILURE;
 	}
@@ -325,9 +321,8 @@ static int keyring_erase(struct credential *c)
  * Table with helper operation callbacks, used by generic
  * credential helper main function.
  */
-static struct credential_operation const credential_helper_ops[] =
-{
-	{ "get",   keyring_get   },
+static struct credential_operation const credential_helper_ops[] = {
+	{ "get",   keyring_get },
 	{ "store", keyring_store },
 	{ "erase", keyring_erase },
 	CREDENTIAL_OP_END
@@ -370,7 +365,7 @@ static int credential_read(struct credential *c)
 		if (!line_len)
 			break;
 
-		value = strchr(buf,'=');
+		value = strchr(buf, '=');
 		if (!value) {
 			g_warning("invalid credential line: %s", key);
 			gnome_keyring_memory_free(buf);
@@ -384,7 +379,7 @@ static int credential_read(struct credential *c)
 		} else if (!strcmp(key, "host")) {
 			g_free(c->host);
 			c->host = g_strdup(value);
-			value = strrchr(c->host,':');
+			value = strrchr(c->host, ':');
 			if (value) {
 				*value++ = '\0';
 				c->port = atoi(value);
@@ -429,16 +424,16 @@ static void credential_write(const struct credential *c)
 static void usage(const char *name)
 {
 	struct credential_operation const *try_op = credential_helper_ops;
-	const char *basename = strrchr(name,'/');
+	const char *basename = strrchr(name, '/');
 
 	basename = (basename) ? basename + 1 : name;
 	fprintf(stderr, "usage: %s <", basename);
 	while (try_op->name) {
-		fprintf(stderr,"%s",(try_op++)->name);
+		fprintf(stderr, "%s", (try_op++)->name);
 		if (try_op->name)
-			fprintf(stderr,"%s","|");
+			fprintf(stderr, "%s", "|");
 	}
-	fprintf(stderr,"%s",">\n");
+	fprintf(stderr, "%s", ">\n");
 }
 
 int main(int argc, char *argv[])
@@ -446,7 +441,7 @@ int main(int argc, char *argv[])
 	int ret = EXIT_SUCCESS;
 
 	struct credential_operation const *try_op = credential_helper_ops;
-	struct credential                  cred   = CREDENTIAL_INIT;
+	struct credential cred = CREDENTIAL_INIT;
 
 	if (!argv[1]) {
 		usage(argv[0]);
-- 
1.8.3.1
Felipe Contreras· Dec 7, 2013, 09:37 UTC · re: John Szakmeister · lore

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

John Szakmeister wrote:
Show 22 quoted lines
> Signed-off-by: John Szakmeister <john@szakmeister.net>
> ---
> 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];
No need for these castings, a gpointer is void *, so there's no need to cast them.
-- 
Felipe Contreras
John Szakmeister· Dec 7, 2013, 10:42 UTC · re: John Szakmeister · lore

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

Signed-off-by: John Szakmeister <john@szakmeister.net>
Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
---
v2 removes some unnecessary casting noticed by Felipe.  Thanks for the
feedback Felipe!
 .../gnome-keyring/git-credential-gnome-keyring.c   | 55 ++++++++++------------
 1 file changed, 25 insertions(+), 30 deletions(-)
Show changes to contrib/credential/gnome-keyring/git-credential-gnome-keyring.c +25 −30
diff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
index 635c96b..302122c 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 = user_data;
+	int *done = data[0];
+	GnomeKeyringResult *r = data[1];
 
 	*r = result;
 	*done = 1;
@@ -132,27 +132,25 @@ static GnomeKeyringResult gnome_keyring_item_delete_sync(const char *keyring, gu
  */
 struct credential
 {
-	char          *protocol;
-	char          *host;
+	char *protocol;
+	char *host;
 	unsigned short port;
-	char          *path;
-	char          *username;
-	char          *password;
+	char *path;
+	char *username;
+	char *password;
 };
 
-#define CREDENTIAL_INIT \
-  { NULL,NULL,0,NULL,NULL,NULL }
+#define CREDENTIAL_INIT { NULL, NULL, 0, NULL, NULL, NULL }
 
-typedef int (*credential_op_cb)(struct credential*);
+typedef int (*credential_op_cb)(struct credential *);
 
 struct credential_operation
 {
-	char             *name;
+	char *name;
 	credential_op_cb op;
 };
 
-#define CREDENTIAL_OP_END \
-  { NULL,NULL }
+#define CREDENTIAL_OP_END { NULL, NULL }
 
 /* ----------------- GNOME Keyring functions ----------------- */
 
@@ -221,7 +219,7 @@ static int keyring_get(struct credential *c)
 static int keyring_store(struct credential *c)
 {
 	guint32 item_id;
-	char  *object = NULL;
+	char *object = NULL;
 	GnomeKeyringResult result;
 
 	/*
@@ -262,7 +260,7 @@ static int keyring_store(struct credential *c)
 
 static int keyring_erase(struct credential *c)
 {
-	char  *object = NULL;
+	char *object = NULL;
 	GList *entries;
 	GnomeKeyringNetworkPasswordData *password_data;
 	GnomeKeyringResult result;
@@ -298,8 +296,7 @@ static int keyring_erase(struct credential *c)
 	if (result == GNOME_KEYRING_RESULT_CANCELLED)
 		return EXIT_SUCCESS;
 
-	if (result != GNOME_KEYRING_RESULT_OK)
-	{
+	if (result != GNOME_KEYRING_RESULT_OK) {
 		g_critical("%s", gnome_keyring_result_to_message(result));
 		return EXIT_FAILURE;
 	}
@@ -312,8 +309,7 @@ static int keyring_erase(struct credential *c)
 
 	gnome_keyring_network_password_list_free(entries);
 
-	if (result != GNOME_KEYRING_RESULT_OK)
-	{
+	if (result != GNOME_KEYRING_RESULT_OK) {
 		g_critical("%s", gnome_keyring_result_to_message(result));
 		return EXIT_FAILURE;
 	}
@@ -325,9 +321,8 @@ static int keyring_erase(struct credential *c)
  * Table with helper operation callbacks, used by generic
  * credential helper main function.
  */
-static struct credential_operation const credential_helper_ops[] =
-{
-	{ "get",   keyring_get   },
+static struct credential_operation const credential_helper_ops[] = {
+	{ "get",   keyring_get },
 	{ "store", keyring_store },
 	{ "erase", keyring_erase },
 	CREDENTIAL_OP_END
@@ -370,7 +365,7 @@ static int credential_read(struct credential *c)
 		if (!line_len)
 			break;
 
-		value = strchr(buf,'=');
+		value = strchr(buf, '=');
 		if (!value) {
 			g_warning("invalid credential line: %s", key);
 			gnome_keyring_memory_free(buf);
@@ -384,7 +379,7 @@ static int credential_read(struct credential *c)
 		} else if (!strcmp(key, "host")) {
 			g_free(c->host);
 			c->host = g_strdup(value);
-			value = strrchr(c->host,':');
+			value = strrchr(c->host, ':');
 			if (value) {
 				*value++ = '\0';
 				c->port = atoi(value);
@@ -429,16 +424,16 @@ static void credential_write(const struct credential *c)
 static void usage(const char *name)
 {
 	struct credential_operation const *try_op = credential_helper_ops;
-	const char *basename = strrchr(name,'/');
+	const char *basename = strrchr(name, '/');
 
 	basename = (basename) ? basename + 1 : name;
 	fprintf(stderr, "usage: %s <", basename);
 	while (try_op->name) {
-		fprintf(stderr,"%s",(try_op++)->name);
+		fprintf(stderr, "%s", (try_op++)->name);
 		if (try_op->name)
-			fprintf(stderr,"%s","|");
+			fprintf(stderr, "%s", "|");
 	}
-	fprintf(stderr,"%s",">\n");
+	fprintf(stderr, "%s", ">\n");
 }
 
 int main(int argc, char *argv[])
@@ -446,7 +441,7 @@ int main(int argc, char *argv[])
 	int ret = EXIT_SUCCESS;
 
 	struct credential_operation const *try_op = credential_helper_ops;
-	struct credential                  cred   = CREDENTIAL_INIT;
+	struct credential cred = CREDENTIAL_INIT;
 
 	if (!argv[1]) {
 		usage(argv[0]);
-- 
1.8.3.1
Junio C Hamano· Dec 9, 2013, 18:06 UTC · re: John Szakmeister · lore

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

John Szakmeister <john@szakmeister.net> writes:
Show 22 quoted lines
> Signed-off-by: John Szakmeister <john@szakmeister.net>
> ---
> 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...
John Szakmeister· Dec 10, 2013, 11:13 UTC · re: Junio C Hamano · lore

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

On Mon, Dec 9, 2013 at 1:06 PM, Junio C Hamano <gitster@pobox.com> 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.

Show 13 quoted lines
> 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.
Junio C Hamano· Dec 12, 2013, 23:41 UTC · re: John Szakmeister · lore

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

John Szakmeister <john@szakmeister.net> writes:
Show 10 quoted lines
> On Mon, Dec 9, 2013 at 1:06 PM, Junio C Hamano <gitster@pobox.com> 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.
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.
Junio C Hamano· Dec 13, 2013, 20:07 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> writes:
Show 28 quoted lines
> John Szakmeister <john@szakmeister.net> writes:
>
>> On Mon, Dec 9, 2013 at 1:06 PM, Junio C Hamano <gitster@pobox.com> 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.
>
> 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.
Here is a squashable diff on top of your clean-up:
 * A few more violations of the same "asterisk sticks to what is the
   pointer, not the name of the type";
 * No SP between (typename) and castee;
 * Opening parenthesis of "struct/union name" comes on the same line
   as the "struct/union" keyword;
 * Opening parenthesis of structured statements e.g. if/while/for/...
   comes on the same line as the starting keyword;
 * Body of structured controls e.g. if/while/... on a separate line.

I may have caught all of them, but I wasn't trying to be super careful, so...

Show changes to contrib/credential/gnome-keyring/git-credential-gnome-keyring.c +14 −16
diff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
index 1613404..d45503c 100644
--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
@@ -60,7 +60,7 @@
 #define gnome_keyring_memory_free gnome_keyring_free_password
 #define gnome_keyring_memory_strdup g_strdup
 
-static const char* gnome_keyring_result_to_message(GnomeKeyringResult result)
+static const char *gnome_keyring_result_to_message(GnomeKeyringResult result)
 {
 	switch (result) {
 	case GNOME_KEYRING_RESULT_OK:
@@ -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];
 
 	*r = result;
 	*done = 1;
@@ -130,8 +130,7 @@ static GnomeKeyringResult gnome_keyring_item_delete_sync(const char *keyring, gu
 /*
  * This credential struct and API is simplified from git's credential.{h,c}
  */
-struct credential
-{
+struct credential {
 	char *protocol;
 	char *host;
 	unsigned short port;
@@ -144,8 +143,7 @@ struct credential
 
 typedef int (*credential_op_cb)(struct credential *);
 
-struct credential_operation
-{
+struct credential_operation {
 	char *name;
 	credential_op_cb op;
 };
@@ -155,7 +153,7 @@ struct credential_operation
 /* ----------------- GNOME Keyring functions ----------------- */
 
 /* create a special keyring option string, if path is given */
-static char* keyring_object(struct credential *c)
+static char *keyring_object(struct credential *c)
 {
 	if (!c->path)
 		return NULL;
@@ -168,7 +166,7 @@ static char* keyring_object(struct credential *c)
 
 static int keyring_get(struct credential *c)
 {
-	char* object = NULL;
+	char *object = NULL;
 	GList *entries;
 	GnomeKeyringNetworkPasswordData *password_data;
 	GnomeKeyringResult result;
@@ -202,7 +200,7 @@ static int keyring_get(struct credential *c)
 	}
 
 	/* pick the first one from the list */
-	password_data = (GnomeKeyringNetworkPasswordData *) entries->data;
+	password_data = (GnomeKeyringNetworkPasswordData *)entries->data;
 
 	gnome_keyring_memory_free(c->password);
 	c->password = gnome_keyring_memory_strdup(password_data->password);
@@ -302,7 +300,7 @@ static int keyring_erase(struct credential *c)
 	}
 
 	/* pick the first one from the list (delete all matches?) */
-	password_data = (GnomeKeyringNetworkPasswordData *) entries->data;
+	password_data = (GnomeKeyringNetworkPasswordData *)entries->data;
 
 	result = gnome_keyring_item_delete_sync(
 		password_data->keyring, password_data->item_id);
@@ -355,12 +353,11 @@ static int credential_read(struct credential *c)
 
 	key = buf = gnome_keyring_memory_alloc(1024);
 
-	while (fgets(buf, 1024, stdin))
-	{
+	while (fgets(buf, 1024, stdin)) {
 		line_len = strlen(buf);
 
 		if (line_len && buf[line_len-1] == '\n')
-			buf[--line_len]='\0';
+			buf[--line_len] = '\0';
 
 		if (!line_len)
 			break;
@@ -393,7 +390,8 @@ static int credential_read(struct credential *c)
 		} else if (!strcmp(key, "password")) {
 			gnome_keyring_memory_free(c->password);
 			c->password = gnome_keyring_memory_strdup(value);
-			while (*value) *value++ = '\0';
+			while (*value)
+				*value++ = '\0';
 		}
 		/*
 		 * Ignore other lines; we don't know what they mean, but
-- 
1.8.5.1-251-gaaad5e7

← back to recent threads