Changeset 7dfe886 for variable.c


Ignore:
Timestamp:
Jun 19, 2011, 2:44:13 AM (13 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
b0e6560
Parents:
9d43dcc
git-author:
Jason Gross <jgross@mit.edu> (06/06/11 05:24:30)
git-committer:
Jason Gross <jgross@mit.edu> (06/19/11 02:44:13)
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

    r9efc154 r7dfe886  
    647647}
    648648
    649 owl_variable * owl_variable_newvar(const char *name, const char *summary, const char * description) {
     649G_GNUC_WARN_UNUSED_RESULT owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description)
     650{
    650651  owl_variable * var = g_new0(owl_variable, 1);
    651652  var->name = g_strdup(name);
     
    825826}
    826827
    827 char *owl_variable_get_tostring(const owl_vardict *d, const char *name) {
     828G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_tostring(const owl_vardict *d, const char *name)
     829{
    828830  owl_variable *v;
    829831  if (!name) return NULL;
     
    833835}
    834836
    835 char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name) {
     837G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name)
     838{
    836839  owl_variable *v;
    837840  if (!name) return NULL;
     
    993996}
    994997
    995 char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val) {
     998G_GNUC_WARN_UNUSED_RESULT char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val)
     999{
    9961000  if (val == NULL) {
    9971001    return g_strdup("<null>");
     
    10281032}
    10291033
    1030 char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val) {
     1034G_GNUC_WARN_UNUSED_RESULT char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val)
     1035{
    10311036  if (val == NULL) {
    10321037    return g_strdup("<null>");
     
    10671072}
    10681073
    1069 char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val) {
     1074G_GNUC_WARN_UNUSED_RESULT char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val)
     1075{
    10701076  char **enums;
    10711077  int nenums, i;
     
    11071113}
    11081114
    1109 char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val) {
     1115G_GNUC_WARN_UNUSED_RESULT char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val)
     1116{
    11101117  if (val == NULL) {
    11111118    return g_strdup("<null>");
Note: See TracChangeset for help on using the changeset viewer.