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 <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Casey committed Sep 23, 2013 at 11:49 UTC 3006297a0e45417e5988536bf5dbeb65ac7cce8d
1 file changed +4 -29
contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
+4 -29
@@ -25,7 +25,6 @@
25
26 #include <stdio.h>
27 #include <string.h>
28 -#include <stdarg.h>
28 #include <stdlib.h>
29 #include <glib.h>
30 #include <gnome-keyring.h>
@@ -58,30 +57,6 @@ struct credential_operation
57 #define CREDENTIAL_OP_END \
58 { NULL,NULL }
59
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 -
60 /* ----------------- GNOME Keyring functions ----------------- */
61
62 /* create a special keyring option string, if path is given */
@@ -127,7 +102,7 @@ static int keyring_get(struct credential *c)
102 return EXIT_SUCCESS;
103
104 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));
106 return EXIT_FAILURE;
107 }
108
@@ -220,7 +195,7 @@ static int keyring_erase(struct credential *c)
195
196 if (result != GNOME_KEYRING_RESULT_OK)
197 {
223 - error("%s",gnome_keyring_result_to_message(result));
198 + g_critical("%s", gnome_keyring_result_to_message(result));
199 return EXIT_FAILURE;
200 }
201
@@ -234,7 +209,7 @@ static int keyring_erase(struct credential *c)
209
210 if (result != GNOME_KEYRING_RESULT_OK)
211 {
237 - error("%s",gnome_keyring_result_to_message(result));
212 + g_critical("%s", gnome_keyring_result_to_message(result));
213 return EXIT_FAILURE;
214 }
215
@@ -292,7 +267,7 @@ static int credential_read(struct credential *c)
267
268 value = strchr(buf,'=');
269 if (!value) {
295 - warning("invalid credential line: %s", key);
270 + g_warning("invalid credential line: %s", key);
271 gnome_keyring_memory_free(buf);
272 return -1;
273 }