Re: [PATCH] X-Operating System in outgoing mail's header



hello,

i am just playing around with your patch and gonna apply
that one within the next minutes but here a comment as far.




> +    gchar * tmp, *format;
> +
> +    format=g_strdup(gtk_entry_get_text(GTK_ENTRY(pui->SystemIdFormat)));
> +    tmp=get_SystemId(format);
> +    gtk_label_set_text(GTK_LABEL (pui->SystemId_preview), tmp);
> +    g_free(tmp);
> +    g_free(format);

gchar *tmp = NULL;
gchar *format = NULL;

...
...
...

if (tmp == NULL)
    g_free (tmp);
if (format == NULL)
    g_free (format);

would be the better solution in case if one of them failed.
e.g. if g_strdup failed or if get_SystemId failed. if one of
the pointers arent getting initialized then you free an
already empty pointer. this causes a warning printed out on
console.

> +    result=(char *)malloc((len+1)*sizeof(char));
> +    if (result==NULL) {
> +        fprintf(stderr, "unable to allocate memory\n");
> +        return NULL;
> +    }

g_malloc in case of compatibility.

> +    snprintf(tooltip_str, TOOLTIPSZ,
> +        "You can use the following sustitutions" \
> +        " to describe your system :\n" \
> +        "%%m machine type (%s)\n" \
> +        "%%h machine's hostname (%s)\n"  \
> +        "%%s operating system name (%s)\n" \
> +        "%%r operating system release (%s)\n" \
> +        "%%v operating system version (%s)\n" \
> +        ,balsa_app.uname.machine,
> +        balsa_app.uname.nodename,
> +        balsa_app.uname.sysname,
> +        balsa_app.uname.release,
> +        balsa_app.uname.version
> +        );

this one too. placing the string into an array is quite evil,
since you don't know how long the array is and if everything
fits inside. i recommend you use g_strdup_printf as far as i
remember theres a more equivalent version of what i recommend
but i am not sure right now this gives you a pointer to a string
back that is more accurate.

at least there are quite a lot of standard 'C' functions used
this works but it would be better to GNOMIFY them with the
replacement gnome functions. this also offers special compatibility
on other plattforms etc.

-- 
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali.akcaagac@stud.fh-wilhelmshaven.de
WWW.....: http://www.fh-wilhelmshaven.de/~akcaagaa




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]