SF.net SVN: geany-plugins:[2132] trunk/geany-plugins/geanypg/src
alvesh88 at users.sourceforge.net
alvesh88 at xxxxx
Sat Aug 13 21:43:28 UTC 2011
Revision: 2132
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=2132&view=rev
Author: alvesh88
Date: 2011-08-13 21:43:28 +0000 (Sat, 13 Aug 2011)
Log Message:
-----------
Fixed a bunch of compiler warnings about shadowing the global index variable
and discarding const qualifiers (string literals are const) and fixed a
function definition (geanypg_validity) which had a wrong parameter type
(gpgme_summary_t instead of gpgme_validity_t).
Modified Paths:
--------------
trunk/geany-plugins/geanypg/src/aux.c
trunk/geany-plugins/geanypg/src/key_selection_dialog.c
trunk/geany-plugins/geanypg/src/pinentry.c
trunk/geany-plugins/geanypg/src/verify_aux.c
Modified: trunk/geany-plugins/geanypg/src/aux.c
===================================================================
--- trunk/geany-plugins/geanypg/src/aux.c 2011-08-13 18:18:32 UTC (rev 2131)
+++ trunk/geany-plugins/geanypg/src/aux.c 2011-08-13 21:43:28 UTC (rev 2132)
@@ -32,24 +32,24 @@
{
gpgme_error_t err;
unsigned long size = SIZE;
- //initialize index to 0
- unsigned long index = 0;
+ //initialize idx to 0
+ unsigned long idx = 0;
//allocate array of size 1N
ed->key_array = (gpgme_key_t*) malloc(SIZE * sizeof(gpgme_key_t));
err = gpgme_op_keylist_start(ed->ctx, NULL, 0);
while (!err)
{
- err = gpgme_op_keylist_next(ed->ctx, ed->key_array + index);
+ err = gpgme_op_keylist_next(ed->ctx, ed->key_array + idx);
if (err)
break;
- ++index;
- if (index >= size)
+ ++idx;
+ if (idx >= size)
{
size += SIZE;
ed->key_array = (gpgme_key_t*) realloc(ed->key_array, size * sizeof(gpgme_key_t));
}
}
- ed->nkeys = index;
+ ed->nkeys = idx;
if (gpg_err_code(err) != GPG_ERR_EOF)
{
geanypg_show_err_msg(err);
@@ -62,24 +62,24 @@
{
gpgme_error_t err;
unsigned long size = SIZE;
- //initialize index to 0
- unsigned long index = 0;
+ //initialize idx to 0
+ unsigned long idx = 0;
//allocate array of size 1N
ed->skey_array = (gpgme_key_t*) malloc(SIZE * sizeof(gpgme_key_t));
err = gpgme_op_keylist_start(ed->ctx, NULL, 1);
while (!err)
{
- err = gpgme_op_keylist_next(ed->ctx, ed->skey_array + index);
+ err = gpgme_op_keylist_next(ed->ctx, ed->skey_array + idx);
if (err)
break;
- ++index;
- if (index >= size)
+ ++idx;
+ if (idx >= size)
{
size += SIZE;
ed->skey_array = (gpgme_key_t*) realloc(ed->skey_array, size * sizeof(gpgme_key_t));
}
}
- ed->nskeys = index;
+ ed->nskeys = idx;
if (gpg_err_code(err) != GPG_ERR_EOF)
{
geanypg_show_err_msg(err);
Modified: trunk/geany-plugins/geanypg/src/key_selection_dialog.c
===================================================================
--- trunk/geany-plugins/geanypg/src/key_selection_dialog.c 2011-08-13 18:18:32 UTC (rev 2131)
+++ trunk/geany-plugins/geanypg/src/key_selection_dialog.c 2011-08-13 21:43:28 UTC (rev 2132)
@@ -53,7 +53,8 @@
static GtkListStore * geanypg_makelist(gpgme_key_t * key_array, unsigned long nkeys, int addnone)
{
GtkTreeIter iter;
- unsigned long index;
+ unsigned long idx;
+ char empty_string = '\0';
GtkListStore * list = gtk_list_store_new(N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING);
if (addnone)
{
@@ -64,17 +65,17 @@
KEYID_COLUMN, "",
-1);
}
- for (index = 0; index < nkeys; ++index)
+ for (idx = 0; idx < nkeys; ++idx)
{
- char * name = (key_array[index]->uids && key_array[index]->uids->name) ? key_array[index]->uids->name : "";
- char * email = (key_array[index]->uids && key_array[index]->uids->email) ? key_array[index]->uids->email : "";
+ char * name = (key_array[idx]->uids && key_array[idx]->uids->name) ? key_array[idx]->uids->name : &empty_string;
+ char * email = (key_array[idx]->uids && key_array[idx]->uids->email) ? key_array[idx]->uids->email : &empty_string;
char buffer[strlen(name) + strlen(email) + 7];
sprintf(buffer, "%s <%s>", name, email);
gtk_list_store_append(list, &iter);
gtk_list_store_set(list, &iter,
TOGGLE_COLUMN, FALSE,
RECIPIENT_COLUMN, buffer,
- KEYID_COLUMN, key_array[index]->subkeys->keyid,
+ KEYID_COLUMN, key_array[idx]->subkeys->keyid,
-1);
}
return list;
@@ -127,7 +128,7 @@
int geanypg_encrypt_selection_dialog(encrypt_data * ed, gpgme_key_t ** selected, int * sign)
{
GtkWidget * dialog = gtk_dialog_new();
- unsigned long index, sindex, capacity;
+ unsigned long idx, sidx, capacity;
int response;
GtkWidget * contentarea, * listview, * scrollwin, * combobox;
GtkTreeIter iter;
@@ -165,11 +166,11 @@
gtk_widget_destroy(dialog);
return 0;
}
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));
- if (index && index <= ed->nskeys)
+ idx = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));
+ if (idx && idx <= ed->nskeys)
{
*sign = 1;
- gpgme_signers_add(ed->ctx, ed->skey_array[index - 1]); // -1 because the first option is `None'
+ gpgme_signers_add(ed->ctx, ed->skey_array[idx - 1]); // -1 because the first option is `None'
}
// try to loop all the keys in the list
// if they are active (the user checked the checkbox in front of the key)
@@ -179,25 +180,25 @@
{
capacity = SIZE;
*selected = (gpgme_key_t*) malloc(SIZE * sizeof(gpgme_key_t));
- index = 0;
- sindex = 0;
+ idx = 0;
+ sidx = 0;
gtk_tree_model_get(GTK_TREE_MODEL(list), &iter, TOGGLE_COLUMN, &active, -1);
if (active)
- (*selected)[sindex++] = ed->key_array[index];
+ (*selected)[sidx++] = ed->key_array[idx];
while (gtk_tree_model_iter_next(GTK_TREE_MODEL(list), &iter))
{
- ++index;
+ ++idx;
gtk_tree_model_get(GTK_TREE_MODEL(list), &iter, TOGGLE_COLUMN, &active, -1);
if (active)
- (*selected)[sindex++] = ed->key_array[index];
- if (sindex >= capacity - 1)
+ (*selected)[sidx++] = ed->key_array[idx];
+ if (sidx >= capacity - 1)
{
capacity += SIZE;
*selected = (gpgme_key_t*) realloc(*selected, capacity * sizeof(gpgme_key_t));
}
}
- (*selected)[sindex] = NULL;
+ (*selected)[sidx] = NULL;
}
else
{
@@ -212,7 +213,7 @@
int geanypg_sign_selection_dialog(encrypt_data * ed)
{
GtkWidget * dialog = gtk_dialog_new();
- unsigned long index;
+ unsigned long idx;
int response;
GtkWidget * contentarea = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
GtkWidget * combobox = geanypg_combobox(
@@ -234,10 +235,10 @@
gtk_widget_destroy(dialog);
return 0;
}
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));
+ idx = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));
gpgme_signers_clear(ed->ctx);
- if (index < ed->nskeys)
- gpgme_signers_add(ed->ctx, ed->skey_array[index]);
+ if (idx < ed->nskeys)
+ gpgme_signers_add(ed->ctx, ed->skey_array[idx]);
gtk_widget_destroy(dialog);
return 1;
Modified: trunk/geany-plugins/geanypg/src/pinentry.c
===================================================================
--- trunk/geany-plugins/geanypg/src/pinentry.c 2011-08-13 18:18:32 UTC (rev 2131)
+++ trunk/geany-plugins/geanypg/src/pinentry.c 2011-08-13 21:43:28 UTC (rev 2132)
@@ -52,15 +52,15 @@
static int geanypg_read(int fd, char delim, int max, char * buffer)
{
- int index, rv = 1;
+ int idx, rv = 1;
char ch = 0;
- for (index = 0; (index < max - 1) && rv && ch != delim; ++index)
+ for (idx = 0; (idx < max - 1) && rv && ch != delim; ++idx)
{
rv = read(fd, &ch, 1);
- buffer[index] = ch;
+ buffer[idx] = ch;
}
- buffer[index ? index - 1 : 0] = 0;
- return index ? index - 1 : 0;
+ buffer[idx ? idx - 1 : 0] = 0;
+ return idx ? idx - 1 : 0;
}
gpgme_error_t geanypg_passphrase_cb(void * hook,
const char * uid_hint,
@@ -89,7 +89,8 @@
childpid = fork();
if (!childpid)
{ // pinentry
- char * argv[] = {"pinentry", NULL};
+ char arg1[] = "pinentry";
+ char * argv[] = {arg1, NULL};
close(outpipe[READ]);
dup2(outpipe[WRITE], STDOUT_FILENO);
Modified: trunk/geany-plugins/geanypg/src/verify_aux.c
===================================================================
--- trunk/geany-plugins/geanypg/src/verify_aux.c 2011-08-13 18:18:32 UTC (rev 2131)
+++ trunk/geany-plugins/geanypg/src/verify_aux.c 2011-08-13 21:43:28 UTC (rev 2132)
@@ -23,17 +23,26 @@
void geanypg_get_keys_with_fp(encrypt_data * ed, char * buffer)
{
- unsigned long index, found = 0;
- for (index = 0; index < ed->nkeys && ! found; ++index)
+ unsigned long idx, found = 0;
+ char empty_string = '\0';
+ for (idx = 0; idx < ed->nkeys && ! found; ++idx)
{
- gpgme_subkey_t sub = ed->key_array[index]->subkeys;
+ gpgme_subkey_t sub = ed->key_array[idx]->subkeys;
while (sub && !found)
{
if (sub->fpr && !strncmp(sub->fpr, buffer, 40))
{
- char * name = (ed->key_array[index]->uids && ed->key_array[index]->uids->name) ? ed->key_array[index]->uids->name : "";
- char * email = (ed->key_array[index]->uids && ed->key_array[index]->uids->email) ? ed->key_array[index]->uids->email : "";
+ char * name = (ed->key_array[idx]->uids && ed->key_array[idx]->uids->name)
+ ?
+ ed->key_array[idx]->uids->name
+ :
+ &empty_string;
+ char * email = (ed->key_array[idx]->uids && ed->key_array[idx]->uids->email)
+ ?
+ ed->key_array[idx]->uids->email
+ :
+ &empty_string;
if (strlen(name) + strlen(email) < 500)
sprintf(buffer, "%s <%s>", name, email);
else
@@ -49,9 +58,9 @@
}
}
-static const char * geanypg_validity(gpgme_sigsum_t summary)
+static const char * geanypg_validity(gpgme_validity_t validity)
{
- switch (summary)
+ switch (validity)
{
case GPGME_VALIDITY_UNKNOWN: return "unknown";
case GPGME_VALIDITY_UNDEFINED:return "undefined";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Plugins-Commits
mailing list