Changeset f4e857f


Ignore:
Timestamp:
Jun 27, 2011, 4:28:51 AM (13 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
0d935a1
Parents:
eeba011
git-author:
Jason Gross <jgross@mit.edu> (06/27/11 02:04:09)
git-committer:
Jason Gross <jgross@mit.edu> (06/27/11 04:28:51)
Message:
Removed some NULL checks for things that really shouldn't ever be NULL

If a BarnOwl variable can't be gotten, then something is horribly wrong,
and if it can't be gotten as a string, then perl will be confused (and
something is probably horribly wrong anyway).

Additionally, our variable descriptions shoud be descriptive.  Valid
settings should not be NULL (and NULL is more likely indicative of
forgetting to set it than actually wanting an empty valid set).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • variable.c

    reeba011 rf4e857f  
    726726
    727727const char *owl_variable_get_validsettings(const owl_variable *v) {
    728   if (v->validsettings) {
    729     return v->validsettings;
    730   } else {
    731     return "";
    732   }
     728  return v->validsettings;
    733729}
    734730
     
    758754    return -1;
    759755  }
    760   if (msg && v->get_tostring_fn) {
     756  if (msg) {
    761757    tostring = v->get_tostring_fn(v, v->get_fn(v));
    762758    owl_function_makemsg("%s = '%s'", name, tostring);
     
    797793  if (!name) return NULL;
    798794  v = owl_dict_find_element(d, name);
    799   if (v == NULL || !v->get_tostring_fn) return NULL;
     795  if (v == NULL) return NULL;
    800796  return v->get_tostring_fn(v, v->get_fn(v));
    801797}
     
    806802  if (!name) return NULL;
    807803  v = owl_dict_find_element(d, name);
    808   if (v == NULL || !v->get_tostring_fn) return NULL;
     804  if (v == NULL) return NULL;
    809805  if (v->type == OWL_VARIABLE_INT || v->type == OWL_VARIABLE_BOOL) {
    810806    return v->get_tostring_fn(v, &(v->ival_default));
     
    819815  if (!name) return(NULL);
    820816  v = owl_dict_find_element(d, name);
    821   if (v == NULL || !v->get_fn) return NULL;
     817  if (v == NULL) return NULL;
    822818  return v;
    823819}
     
    862858
    863859  if (!name
    864       || (v = owl_dict_find_element(d, name)) == NULL
    865       || !v->get_fn) {
     860      || (v = owl_dict_find_element(d, name)) == NULL) {
    866861    owl_fmtext_appendf_normal(fm, "     No such variable '%s'\n", name);
    867862    return;
     
    883878
    884879  if (!name
    885       || (v = owl_dict_find_element(d, name)) == NULL
    886       || !v->get_fn) {
     880      || (v = owl_dict_find_element(d, name)) == NULL) {
    887881    owl_fmtext_append_normal(fm, "No such variable...\n");
    888882    return;
Note: See TracChangeset for help on using the changeset viewer.