Skip to content

Commit a47b873

Browse files
pks-tgitster
authored andcommitted
contrib/credential: fix compiling "libsecret" helper
The "libsecret" credential helper does not compile when developer warnings are enabled due to three warnings: - contrib/credential/libsecret/git-credential-libsecret.c:78:1: missing initializer for field ‘reserved’ of ‘SecretSchema’ [-Werror=missing-field-initializers]. This issue is fixed by using designated initializers. - contrib/credential/libsecret/git-credential-libsecret.c:171:43: comparison of integer expressions of different signedness: ‘int’ and ‘guint’ {aka ‘unsigned int’} [-Werror=sign-compare]. This issue is fixed by using an unsigned variable to iterate through the string vector. - contrib/credential/libsecret/git-credential-libsecret.c:420:14: unused parameter ‘argc’ [-Werror=unused-parameter]. This issue is fixed by checking the number of arguments, but in the least restrictive way possible. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f8d95a3 commit a47b873

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

contrib/credential/libsecret/git-credential-libsecret.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ static void credential_clear(struct credential *c);
5959
/* ----------------- Secret Service functions ----------------- */
6060

6161
static const SecretSchema schema = {
62-
"org.git.Password",
62+
.name = "org.git.Password",
6363
/* Ignore schema name during search for backwards compatibility */
64-
SECRET_SCHEMA_DONT_MATCH_NAME,
65-
{
64+
.flags = SECRET_SCHEMA_DONT_MATCH_NAME,
65+
.attributes = {
6666
/*
6767
* libsecret assumes attribute values are non-confidential and
6868
* unchanging, so we can't include oauth_refresh_token or
@@ -168,7 +168,7 @@ static int keyring_get(struct credential *c)
168168
g_free(c->password);
169169
c->password = g_strdup("");
170170
}
171-
for (int i = 1; i < g_strv_length(parts); i++) {
171+
for (guint i = 1; i < g_strv_length(parts); i++) {
172172
if (g_str_has_prefix(parts[i], "password_expiry_utc=")) {
173173
g_free(c->password_expiry_utc);
174174
c->password_expiry_utc = g_strdup(&parts[i][20]);
@@ -424,7 +424,7 @@ int main(int argc, char *argv[])
424424
struct credential_operation const *try_op = credential_helper_ops;
425425
struct credential cred = CREDENTIAL_INIT;
426426

427-
if (!argv[1]) {
427+
if (argc < 2 || !*argv[1]) {
428428
usage(argv[0]);
429429
exit(EXIT_FAILURE);
430430
}

0 commit comments

Comments
 (0)