Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwife.git;a=commitdiff;h=d03ea4548061ea9b9290fcbdbcf4018c09bb05f2

commit d03ea4548061ea9b9290fcbdbcf4018c09bb05f2
Author: Elentir <elen...@mailoo.org>
Date:   Sat Feb 20 22:43:40 2010 +0100

others small changes

* use MALLOC macro everywhere
* some trailling whitespaces

diff --git a/src/plugins/asklang.c b/src/plugins/asklang.c
index b88bfbb..eabb270 100644
--- a/src/plugins/asklang.c
+++ b/src/plugins/asklang.c
@@ -4,7 +4,7 @@
*  Copyright (c) 2005, 2007, 2008 by Miklos Vajna <vmik...@frugalware.org>
*  Copyright (c) 2005 by Christian Hamar alias krix <kr...@linuxforum.hu>
*  Copyright (c) 2008, 2009 by Albar Boris <bori...@cegetel.net>
- *
+ *
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
@@ -20,7 +20,7 @@
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
*  USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -114,11 +114,11 @@ GtkWidget *load_gtk_widget()
GtkTreeSelection *selection;
GdkPixbuf *pix;
char *path;
-
+
// Create a tree view list for displaying languages
store = gtk_list_store_new(COLUMN_LANG_NUMS, GDK_TYPE_PIXBUF, G_TYPE_STRING, 
G_TYPE_STRING);
model = GTK_TREE_MODEL(store);
-
+
view = gtk_tree_view_new_with_model(model);
g_object_unref (model);
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
@@ -132,19 +132,19 @@ GtkWidget *load_gtk_widget()
renderer = gtk_cell_renderer_text_new();
col = gtk_tree_view_column_new_with_attributes (_("Code"), renderer, "text", 
COLUMN_LANG_CODE, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
-
+
//* Column for language name *//
renderer = gtk_cell_renderer_text_new();
col = gtk_tree_view_column_new_with_attributes (_("Name"), renderer, "text", 
COLUMN_LANG_NAME, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
-
+
//* Set all languages with flag *//
GError *gerror = NULL;
-       for(i=0; i<(LANGSNUM*2); i+=2)
-       {
+       for(i=0; i<(LANGSNUM*2); i+=2)
+       {
//load appropriate image
path = g_strdup_printf("%s/flags/%s", IMAGEDIR, langs[i]);
-               pix = gdk_pixbuf_new_from_file (path, &gerror);
+               pix = gdk_pixbuf_new_from_file (path, &gerror);
if(gerror != NULL) {
LOG("Error when loading image : %s", path);
}
@@ -157,10 +157,10 @@ GtkWidget *load_gtk_widget()

selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
-
+
//* Just a scrollbar if many languages *//
pScrollbar = gtk_scrolled_window_new(NULL, NULL);
-
+
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(pScrollbar), view);
//* Disable scrollbar if useless (few languages) *//
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(pScrollbar), 
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -191,7 +191,7 @@ int run(GList **config)
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
-
+
if(!strcmp("en_US", selected))
setenv("CHARSET", "iso-8859-1", 1);
else if(!strcmp("es_AR", selected))
diff --git a/src/plugins/configsource.c b/src/plugins/configsource.c
index 1330ee0..76ffde3 100644
--- a/src/plugins/configsource.c
+++ b/src/plugins/configsource.c
@@ -479,15 +479,16 @@ void free_wifi_ap(struct wifi_ap *ap)
/* Parser for iwlist command */
GList *list_entry_points(char *ifacename)
{
-       char *line = malloc(256);
+       char *line = NULL;
size_t len = 0;
FILE * fp = NULL;
char *command = NULL;
struct wifi_ap *ap = NULL;
char *tok = NULL;
-
GList *entrys = NULL;

+       MALLOC(line, 256);
+
/* up interface */
command = g_strdup_printf("ifconfig %s up", ifacename);
system(command);
@@ -503,7 +504,7 @@ GList *list_entry_points(char *ifacename)
else
free_wifi_ap(ap);

-                               ap = malloc(sizeof(struct wifi_ap));
+                               MALLOC(ap, sizeof(struct wifi_ap));
memset(ap, 0, sizeof(struct wifi_ap));
strchr(tok+9, '\n')[0] = '\0';
ap->address = strdup(tok+9);
@@ -1111,12 +1112,10 @@ int run_net_config(GList **config)
/* profile used do write configuration */
fwnet_profile_t *newprofile = NULL;

-       if((newprofile = (fwnet_profile_t*)malloc(sizeof(fwnet_profile_t))) == 
NULL)
-               return 1;
+       MALLOC(newprofile, sizeof(fwnet_profile_t));
memset(newprofile, 0, sizeof(fwnet_profile_t));

-       if((newinterface = 
(fwnet_interface_t*)malloc(sizeof(fwnet_interface_t))) == NULL)
-               return 1;
+       MALLOC(newinterface, sizeof(fwnet_interface_t));
memset(newinterface, 0, sizeof(fwnet_interface_t));

if(is_connected("www.google.com", 80, 2) == 1) {
diff --git a/src/plugins/greet.c b/src/plugins/greet.c
index 0671687..5768c9d 100644
--- a/src/plugins/greet.c
+++ b/src/plugins/greet.c
@@ -18,7 +18,7 @@
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
*  USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/src/plugins/grubconf.c b/src/plugins/grubconf.c
index c268b0b..2f800b0 100644
--- a/src/plugins/grubconf.c
+++ b/src/plugins/grubconf.c
@@ -81,13 +81,13 @@ GtkWidget *load_gtk_widget(void)
/* Set up radio buttons */
pRadio1 = gtk_radio_button_new_with_label(NULL, _("MBR  -  Install to Master 
Boot Record"));
gtk_box_pack_start(GTK_BOX (pVBox), pRadio1, FALSE, FALSE, 0);
-
+
GtkWidget *pRadio2 = 
gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (pRadio1), 
_("Floppy  -  Install to a formatted floppy in /dev/fd0"));
gtk_box_pack_start(GTK_BOX (pVBox), pRadio2, FALSE, FALSE, 0);
-
+
GtkWidget *pRadio3 = 
gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (pRadio1), _("Root 
 -  Install to superblock (do NOT use with XFS)"));
gtk_box_pack_start(GTK_BOX (pVBox), pRadio3, FALSE, FALSE, 0);
-
+
GtkWidget *pRadio4 = 
gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (pRadio1), _("Skip 
 -  Skip the installation of GRUB."));
gtk_box_pack_start(GTK_BOX (pVBox), pRadio4, FALSE, FALSE, 0);

@@ -139,7 +139,6 @@ int run(GList **config)
else if(pid == 0)
{
chroot(TARGETDIR);
-
//* Install grub and menu *//
if(mode!=3)
{
diff --git a/src/plugins/layout.c b/src/plugins/layout.c
index ac7066e..08dbd41 100644
--- a/src/plugins/layout.c
+++ b/src/plugins/layout.c
@@ -82,7 +82,7 @@ int find_languages(char *dirname)
struct stat statbuf;
char *fn = NULL;
FILE *fp = NULL;
-       char *line = malloc(128);
+       char *line = NULL;
size_t len = 0;
int i;

@@ -95,6 +95,8 @@ int find_languages(char *dirname)
char *consolemap = NULL;
char *variante = NULL;

+       MALLOC(line, 128);
+
DIR *dir = opendir(dirname);
if (!dir) {
perror(dirname);
@@ -229,7 +231,9 @@ void model_changed(GtkWidget *combo, gpointer data)
size_t len = 0;
FILE * fp = NULL;
char *file = NULL;
-       char *line = malloc(256);
+       char *line = NULL;
+
+       MALLOC(line, 256);

if(strcmp((char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)), "")) {
file = g_strdup_printf("/usr/share/X11/xkb/symbols/%s", 
(char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)));
diff --git a/src/plugins/netconf.c b/src/plugins/netconf.c
index 33f9721..528e088 100644
--- a/src/plugins/netconf.c
+++ b/src/plugins/netconf.c
@@ -121,7 +121,7 @@ void free_wifi_ap(struct wifi_ap *ap)
/* Parser for iwlist command */
GList *list_entry_points(char *ifacename)
{
-       char *line = malloc(256);
+       char *line = NULL;
size_t len = 0;
FILE * fp = NULL;
char *command = NULL;
@@ -130,6 +130,8 @@ GList *list_entry_points(char *ifacename)

GList *entrys = NULL;

+       MALLOC(line, 256);
+
/* up interface */
command = g_strdup_printf("ifconfig %s up", ifacename);
system(command);
@@ -143,7 +145,7 @@ GList *list_entry_points(char *ifacename)
if(ap != NULL)
entrys = g_list_append(entrys, ap);

-                               ap = malloc(sizeof(struct wifi_ap));
+                               MALLOC(ap, sizeof(struct wifi_ap));
memset(ap, 0, sizeof(struct wifi_ap));
strchr(tok+9, '\n')[0] = '\0';
ap->address = strdup(tok+9);
@@ -676,8 +678,7 @@ int add_interface(GtkWidget *button, gpointer data)
}
}

-       if((newinterface = 
(fwnet_interface_t*)malloc(sizeof(fwnet_interface_t))) == NULL)
-               return(-1);
+       MALLOC(newinterface, sizeof(fwnet_interface_t));
memset(newinterface, 0, sizeof(fwnet_interface_t));

snprintf(newinterface->name, IF_NAMESIZE, iface);
@@ -837,16 +838,15 @@ Do you want to apply the current configuration ?")))
for(i=0; i<g_list_length(iflist); i+=2) {
gtk_list_store_append(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(viewif))),
 &iter);
gtk_list_store_set(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(viewif))),
 &iter, COLUMN_NET_IMAGE, connectimg,
-                                                                               
                                                                                
COLUMN_NET_NAME, (char*)g_list_nth_data(iflist, i),
-                                                                               
                                                                                
COLUMN_NET_DESC, (char*)g_list_nth_data(iflist, i+1),
-                                                                               
                                                                                
COLUMN_NET_TYPE, "",
-                                                                               
                                                                                
-1);
+                                       COLUMN_NET_NAME, 
(char*)g_list_nth_data(iflist, i),
+                                       COLUMN_NET_DESC, 
(char*)g_list_nth_data(iflist, i+1),
+                                       COLUMN_NET_TYPE, "",
+                                       -1);
}
}

free(newprofile);
-       if((newprofile = (fwnet_profile_t*)malloc(sizeof(fwnet_profile_t))) == 
NULL)
-               return(1);
+       MALLOC(newprofile, sizeof(fwnet_profile_t));
memset(newprofile, 0, sizeof(fwnet_profile_t));

return 0;
diff --git a/src/plugins/partdisk.c b/src/plugins/partdisk.c
index 459492c..b7f0c96 100644
--- a/src/plugins/partdisk.c
+++ b/src/plugins/partdisk.c
@@ -134,7 +134,7 @@ int partdetails(PedPartition *part, int noswap)

size = fsize(part->geom.length);

-       partinfo = malloc(sizeof(struct fwife_part_info_t));
+       MALLOC(partinfo, sizeof(struct fwife_part_info_t));
memset(partinfo, 0, sizeof(struct fwife_part_info_t));

partinfo->dev = pname;
diff --git a/src/plugins/select.c b/src/plugins/select.c
index ed77ef8..625835e 100644
--- a/src/plugins/select.c
+++ b/src/plugins/select.c
@@ -1167,7 +1167,8 @@ int run(GList **config)
char *ptr;
GList *allpkgs = NULL;
long long pkgsize=0, freespace;
-       long long *compressedsize = malloc(sizeof(long long));
+       long long *compressedsize = NULL;
+       MALLOC(compressedsize, sizeof(long long));
*compressedsize = 0;

if(cats == NULL)
diff --git a/src/util.c b/src/util.c
index 4b73824..578a535 100644
--- a/src/util.c
+++ b/src/util.c
@@ -51,11 +51,11 @@ long long get_freespace(void)
struct mntent *mnt;
char *table = MOUNTED;
FILE *fp;
-       long long ret=0;
+       long long ret = 0;

fp = setmntent (table, "r");
if(!fp)
-                       return(-1);
+               return(-1);
while ((mnt = getmntent (fp)))
{
if(strstr(mnt->mnt_dir, "/mnt/target") != NULL) {
@@ -70,13 +70,13 @@ long long get_freespace(void)

data_t *data_new(void)
{
-       data_t *data=NULL;
+       data_t *data = NULL;

data = (data_t*)malloc(sizeof(data_t));
-       if(data==NULL)
+       if(data == NULL)
return(NULL);
-       data->name=NULL;
-       data->data=NULL;
+       data->name = NULL;
+       data->data = NULL;
return(data);
}

@@ -85,7 +85,7 @@ void *data_get(GList *config, char *title)
int i;
data_t *data;

-       for (i=0; i<g_list_length(config); i++)
+       for (i=0; i < g_list_length(config); i++)
{
data = g_list_nth_data(config, i);
if(!strcmp(title, data->name))
@@ -214,7 +214,7 @@ int umount_if_needed(char *sourcedir)
{
FILE *fp;
char line[PATH_MAX];
-       char *dev=NULL;
+       char *dev = NULL;
char *realdir;
int i;
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to