Skip to content

Commit 3006297

Browse files
drafnelgitster
authored andcommitted
contrib/git-credential-gnome-keyring.c: use glib messaging functions
Rather than roll our own, let's use the messaging functions provided by glib. Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 68a65f5 commit 3006297

File tree

1 file changed

+4
-29
lines changed

1 file changed

+4
-29
lines changed

contrib/credential/gnome-keyring/git-credential-gnome-keyring.c

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#include <stdio.h>
2727
#include <string.h>
28-
#include <stdarg.h>
2928
#include <stdlib.h>
3029
#include <glib.h>
3130
#include <gnome-keyring.h>
@@ -58,30 +57,6 @@ struct credential_operation
5857
#define CREDENTIAL_OP_END \
5958
{ NULL,NULL }
6059

61-
/* ---------------- common helper functions ----------------- */
62-
63-
static inline void warning(const char *fmt, ...)
64-
{
65-
va_list ap;
66-
67-
va_start(ap, fmt);
68-
fprintf(stderr, "warning: ");
69-
vfprintf(stderr, fmt, ap);
70-
fprintf(stderr, "\n" );
71-
va_end(ap);
72-
}
73-
74-
static inline void error(const char *fmt, ...)
75-
{
76-
va_list ap;
77-
78-
va_start(ap, fmt);
79-
fprintf(stderr, "error: ");
80-
vfprintf(stderr, fmt, ap);
81-
fprintf(stderr, "\n" );
82-
va_end(ap);
83-
}
84-
8560
/* ----------------- GNOME Keyring functions ----------------- */
8661

8762
/* create a special keyring option string, if path is given */
@@ -127,7 +102,7 @@ static int keyring_get(struct credential *c)
127102
return EXIT_SUCCESS;
128103

129104
if (result != GNOME_KEYRING_RESULT_OK) {
130-
error("%s",gnome_keyring_result_to_message(result));
105+
g_critical("%s", gnome_keyring_result_to_message(result));
131106
return EXIT_FAILURE;
132107
}
133108

@@ -220,7 +195,7 @@ static int keyring_erase(struct credential *c)
220195

221196
if (result != GNOME_KEYRING_RESULT_OK)
222197
{
223-
error("%s",gnome_keyring_result_to_message(result));
198+
g_critical("%s", gnome_keyring_result_to_message(result));
224199
return EXIT_FAILURE;
225200
}
226201

@@ -234,7 +209,7 @@ static int keyring_erase(struct credential *c)
234209

235210
if (result != GNOME_KEYRING_RESULT_OK)
236211
{
237-
error("%s",gnome_keyring_result_to_message(result));
212+
g_critical("%s", gnome_keyring_result_to_message(result));
238213
return EXIT_FAILURE;
239214
}
240215

@@ -292,7 +267,7 @@ static int credential_read(struct credential *c)
292267

293268
value = strchr(buf,'=');
294269
if (!value) {
295-
warning("invalid credential line: %s", key);
270+
g_warning("invalid credential line: %s", key);
296271
gnome_keyring_memory_free(buf);
297272
return -1;
298273
}

0 commit comments

Comments
 (0)