[Openvas-commits] r2946 - in trunk/openvas-client: . nessus
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Mar 30 09:49:27 CEST 2009
Author: felix
Date: 2009-03-30 09:49:26 +0200 (Mon, 30 Mar 2009)
New Revision: 2946
Modified:
trunk/openvas-client/ChangeLog
trunk/openvas-client/nessus/preferences.c
Log:
Stricter use of g_free for strings allocated by glib, reformatting,
typo fixed, use of g_strdup_printf instead of fixed-size array.
* nessus/preferences.c: Changed return type of preferences_get_filename
indeed a gchar*, and many other occurences where gchar* were handled as
char* (important only when free'ing), reformatting.
* nessus/preferences.c (new_pluginset): Use g_strdup instead of
statically sized array.
* nessus/preferences.c (preferences_save_as): Removed favorite typo
(automagically).
Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog 2009-03-30 07:32:08 UTC (rev 2945)
+++ trunk/openvas-client/ChangeLog 2009-03-30 07:49:26 UTC (rev 2946)
@@ -1,5 +1,20 @@
2009-03-30 Felix Wolfsteller <felix.wolfsteller at intevation.de>
+ Stricter use of g_free for strings allocated by glib, reformatting,
+ typo fixed, use of g_strdup_printf instead of fixed-size array.
+
+ * nessus/preferences.c: Changed return type of preferences_get_filename
+ indeed a gchar*, and many other occurences where gchar* were handled as
+ char* (important only when free'ing), reformatting.
+
+ * nessus/preferences.c (new_pluginset): Use g_strdup instead of
+ statically sized array.
+
+ * nessus/preferences.c (preferences_save_as): Removed favorite typo
+ (automagically).
+
+2009-03-30 Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
Tackled compiler warnings (const poison).
* src/gui/severity_override_form.c (add_override_to_global_filter,
Modified: trunk/openvas-client/nessus/preferences.c
===================================================================
--- trunk/openvas-client/nessus/preferences.c 2009-03-30 07:32:08 UTC (rev 2945)
+++ trunk/openvas-client/nessus/preferences.c 2009-03-30 07:49:26 UTC (rev 2946)
@@ -80,10 +80,10 @@
*
* @return The location of the contexts openvasrc.
*/
-char *
-preferences_get_filename(struct context * context)
+gchar *
+preferences_get_filename (struct context * context)
{
- char * openvasrc;
+ gchar * openvasrc;
if(context->dir)
{
@@ -95,7 +95,7 @@
openvasrc = estrdup(Alt_rcfile);
else
{
- char *home = prefs_get_nessushome();
+ gchar *home = prefs_get_nessushome();
openvasrc = g_build_filename (home, ".openvasrc", NULL);
}
@@ -106,23 +106,26 @@
char *
preferences_get_altname (struct context *context, const char *ext)
{
- char *nessusrc = preferences_get_filename(context);
+ gchar *nessusrc = preferences_get_filename (context);
- if(ext && strlen(ext))
+ if (ext && strlen(ext))
{
- char *ret = g_strdup_printf ("%s.%s", nessusrc, ext);
- efree(&nessusrc);
+ gchar *ret = g_strdup_printf ("%s.%s", nessusrc, ext);
+ g_free (nessusrc);
return ret;
}
else
return nessusrc;
}
+/**
+ * @return -1 in case of error, 0 otherwise.
+ */
static int
preferences_new (struct context* context)
{
FILE *f;
- char *fn = preferences_get_filename(context);
+ gchar *fn = preferences_get_filename(context);
if(!fn)
return (-1);
@@ -168,9 +171,9 @@
fprintf(f, "end(SERVER_PREFS)\n");
}
- fclose(f);
- chmod(fn, 0600);
- efree(&fn);
+ fclose (f);
+ chmod (fn, 0600);
+ g_free (fn);
return (0);
}
@@ -181,7 +184,7 @@
}
int
-preferences_process_filename (struct context *context, char *filename)
+preferences_process_filename (struct context *context, gchar *filename)
{
FILE *fd;
char *buffer;
@@ -189,7 +192,7 @@
if(default_filename)
{
- filename = preferences_get_filename(context);
+ filename = preferences_get_filename (context);
chmod(filename, 0600);
}
@@ -389,11 +392,10 @@
{
while(plugins != NULL )
{
- char name[40];
-
- snprintf(name, sizeof(name), "%s", plugins->oid);
+ gchar* name = g_strdup (plugins->oid);
arg_add_value(pluginset, name, ARG_INT, sizeof(gpointer), GSIZE_TO_POINTER(plugins->enabled != 0) );
plugins = plugins->next;
+ g_free (name);
}
}
@@ -522,7 +524,7 @@
return;
}
chmod(filename, 0600);
- fprintf(fd, _("# This file was automagically created by OpenVAS-Client\n"));
+ fprintf(fd, _("# This file was automatically created by OpenVAS-Client\n"));
pluginset_reload(context, "PLUGIN_SET", context->plugins);
pluginset_reload(context, "SCANNER_SET", context->scanners);
@@ -594,12 +596,12 @@
if(copy_from)
{
context_type type = copy_from->type;
- char *filename = preferences_get_filename(context);
+ gchar *filename = preferences_get_filename (context);
copy_from->type = context->type;
preferences_save_as(copy_from, filename);
copy_from->type = type;
- efree(&filename);
+ g_free (filename);
}
else
preferences_new(context);
@@ -615,16 +617,15 @@
#ifdef USE_GTK
gboolean
-prefs_is_executable(name)
- gchar *name;
+prefs_is_executable (gchar *name)
{
- gchar *prog = g_find_program_in_path(name);
+ gchar *prog = g_find_program_in_path (name);
- if(prog)
- {
- g_free(prog);
- return TRUE;
- }
+ if (prog)
+ {
+ g_free (prog);
+ return TRUE;
+ }
else
return FALSE;
}
@@ -849,15 +850,15 @@
struct passwd *pwd;
home = getenv("NESSUSHOME");
- if(home)
+ if (home)
return home;
- home = getenv("HOME");
- if(home)
+ home = getenv ("HOME");
+ if (home)
return home;
- pwd = getpwuid(getuid());
- if(pwd && pwd->pw_dir)
+ pwd = getpwuid (getuid());
+ if (pwd && pwd->pw_dir)
return pwd->pw_dir;
return "";
More information about the Openvas-commits
mailing list