Changeset d427f08 for variable.c


Ignore:
Timestamp:
Jun 22, 2011, 3:40:50 PM (10 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
b343c2c
Parents:
84a071f
git-author:
Jason Gross <jgross@mit.edu> (06/06/11 05:24:30)
git-committer:
Nelson Elhage <nelhage@mit.edu> (06/22/11 15:40:50)
Message:
Use G_GNUC_WARN_UNUSED_RESULT

Have gcc warn us when we ignore the result of a function that requires
the caller to free the result, or an initilization function that can
fail.  This might help (slightly) with preventing leaks and segfaults.

Additionally changed some functions that should never fail to not
return values.  (The owl_list_* functions changed only fail if
list->size < 0, which we assume is not the case elsewhere.)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • variable.c

    r72146c7 rd427f08  
    646646}
    647647
    648 owl_variable * owl_variable_newvar(const char *name, const char *summary, const char * description) {
     648G_GNUC_WARN_UNUSED_RESULT owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description)
     649{
    649650  owl_variable * var = g_new0(owl_variable, 1);
    650651  var->name = g_strdup(name);
     
    824825}
    825826
    826 char *owl_variable_get_tostring(const owl_vardict *d, const char *name) {
     827G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_tostring(const owl_vardict *d, const char *name)
     828{
    827829  owl_variable *v;
    828830  if (!name) return NULL;
     
    832834}
    833835
    834 char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name) {
     836G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name)
     837{
    835838  owl_variable *v;
    836839  if (!name) return NULL;
     
    992995}
    993996
    994 char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val) {
     997G_GNUC_WARN_UNUSED_RESULT char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val)
     998{
    995999  if (val == NULL) {
    9961000    return g_strdup("<null>");
     
    10271031}
    10281032
    1029 char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val) {
     1033G_GNUC_WARN_UNUSED_RESULT char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val)
     1034{
    10301035  if (val == NULL) {
    10311036    return g_strdup("<null>");
     
    10661071}
    10671072
    1068 char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val) {
     1073G_GNUC_WARN_UNUSED_RESULT char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val)
     1074{
    10691075  char **enums;
    10701076  int nenums, i;
     
    11061112}
    11071113
    1108 char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val) {
     1114G_GNUC_WARN_UNUSED_RESULT char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val)
     1115{
    11091116  if (val == NULL) {
    11101117    return g_strdup("<null>");
Note: See TracChangeset for help on using the changeset viewer.