Changeset d427f08


Ignore:
Timestamp:
Jun 22, 2011, 3:40:50 PM (13 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, 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.)
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • aim.c

    r6b0b4f4 rd427f08  
    437437
    438438/* caller must free the return */
    439 char *owl_aim_normalize_screenname(const char *in)
     439G_GNUC_WARN_UNUSED_RESULT char *owl_aim_normalize_screenname(const char *in)
    440440{
    441441  char *out;
  • cmd.c

    raad166a rd427f08  
    99/**************************************************************************/
    1010
    11 int owl_cmddict_setup(owl_cmddict *cd) {
     11void owl_cmddict_setup(owl_cmddict *cd)
     12{
    1213  owl_cmddict_init(cd);
    13   return owl_cmd_add_defaults(cd);
     14  owl_cmd_add_defaults(cd);
    1415}
    1516
     
    1920
    2021/* for bulk initialization at startup */
    21 int owl_cmddict_add_from_list(owl_cmddict *cd, const owl_cmd *cmds) {
     22void owl_cmddict_add_from_list(owl_cmddict *cd, const owl_cmd *cmds)
     23{
    2224  const owl_cmd *cur;
    23   int ret = 0;
    2425  for (cur = cmds; cur->name != NULL; cur++) {
    25     ret = owl_cmddict_add_cmd(cd, cur);
    26     if (ret < 0) break;
    27   }
    28   return ret;
     26    owl_cmddict_add_cmd(cd, cur);
     27  }
    2928}
    3029
     
    3837
    3938/* creates a new command alias */
    40 int owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) {
     39void owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) {
    4140  owl_cmd *cmd;
    4241  cmd = g_new(owl_cmd, 1);
     
    4443  owl_perlconfig_new_command(cmd->name);
    4544  owl_dict_insert_element(cd, cmd->name, cmd, (void (*)(void *))owl_cmd_delete);
    46   return(0);
    4745}
    4846
     
    5755}
    5856
    59 char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff) {
     57/* caller must free the return */
     58G_GNUC_WARN_UNUSED_RESULT char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff)
     59{
    6060  char *retval = NULL;
    6161  const owl_cmd *cmd;
     
    7272}
    7373
    74 char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff) {
     74/* caller must free the return */
     75G_GNUC_WARN_UNUSED_RESULT char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff)
     76{
    7577  char **argv;
    7678  int argc;
     
    9496}
    9597
    96 char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc) {
     98/* caller must free the return */
     99G_GNUC_WARN_UNUSED_RESULT char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc)
     100{
    97101  char *buff;
    98102  char *retval = NULL;
     
    121125}
    122126
    123 int owl_cmd_create_alias(owl_cmd *cmd, const char *name, const char *aliased_to) {
     127void owl_cmd_create_alias(owl_cmd *cmd, const char *name, const char *aliased_to) {
    124128  memset(cmd, 0, sizeof(owl_cmd));
    125129  cmd->name = g_strdup(name);
    126130  cmd->cmd_aliased_to = g_strdup(aliased_to);
    127131  cmd->summary = g_strdup_printf("%s%s", OWL_CMD_ALIAS_SUMMARY_PREFIX, aliased_to);
    128   return(0);
    129132}
    130133
     
    150153}
    151154
    152 char *owl_cmd_execute(const owl_cmd *cmd, const owl_cmddict *cd, const owl_context *ctx, int argc, const char *const *argv, const char *cmdbuff) {
     155/* caller must free the result */
     156G_GNUC_WARN_UNUSED_RESULT char *owl_cmd_execute(const owl_cmd *cmd, const owl_cmddict *cd, const owl_context *ctx, int argc, const char *const *argv, const char *cmdbuff)
     157{
    153158  static int alias_recurse_depth = 0;
    154159  int ival=0;
     
    223228
    224229/* returns a summary line describing this keymap.  the caller must free. */
    225 char *owl_cmd_describe(const owl_cmd *cmd) {
     230G_GNUC_WARN_UNUSED_RESULT char *owl_cmd_describe(const owl_cmd *cmd)
     231{
    226232  if (!cmd || !cmd->name || !cmd->summary) return NULL;
    227233  return g_strdup_printf("%-25s - %s", cmd->name, cmd->summary);
  • commands.c

    r58f4fb2 rd427f08  
    4141
    4242
    43 int owl_cmd_add_defaults(owl_cmddict *cd)
     43void owl_cmd_add_defaults(owl_cmddict *cd)
    4444{
    4545  owl_cmd commands_to_init[] = {
     
    10401040  };
    10411041
    1042   int ret = owl_cmddict_add_from_list(cd, commands_to_init);
     1042  owl_cmddict_add_from_list(cd, commands_to_init);
    10431043  owl_cmd *cmd;
    10441044  for (cmd = commands_to_init; cmd->name != NULL; cmd++)
    10451045    owl_cmd_cleanup(cmd);
    1046   return ret;
    10471046}
    10481047
     
    13741373}
    13751374
    1376 char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
     1375G_GNUC_WARN_UNUSED_RESULT char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
    13771376{
    13781377  char *filtname = NULL;
     
    14141413}
    14151414
    1416 char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
     1415G_GNUC_WARN_UNUSED_RESULT char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
    14171416{
    14181417  if(argc != 1)
     
    16451644
    16461645
    1647 char *owl_command_exec(int argc, const char *const *argv, const char *buff)
     1646G_GNUC_WARN_UNUSED_RESULT char *owl_command_exec(int argc, const char *const *argv, const char *buff)
    16481647{
    16491648  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_RETURN);
    16501649}
    16511650
    1652 char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
     1651G_GNUC_WARN_UNUSED_RESULT char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
    16531652{
    16541653  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_POPUP);
    16551654}
    16561655
    1657 char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
     1656G_GNUC_WARN_UNUSED_RESULT char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
    16581657{
    16591658  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_ADMINMSG);
    16601659}
    16611660
    1662 char *owl_command_perl(int argc, const char *const *argv, const char *buff)
     1661G_GNUC_WARN_UNUSED_RESULT char *owl_command_perl(int argc, const char *const *argv, const char *buff)
    16631662{
    16641663  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_RETURN);
    16651664}
    16661665
    1667 char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
     1666G_GNUC_WARN_UNUSED_RESULT char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
    16681667{
    16691668  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_POPUP);
    16701669}
    16711670
    1672 char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
     1671G_GNUC_WARN_UNUSED_RESULT char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
    16731672{
    16741673  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_ADMINMSG);
    16751674}
    16761675
    1677 char *owl_command_multi(int argc, const char *const *argv, const char *buff)
     1676G_GNUC_WARN_UNUSED_RESULT char *owl_command_multi(int argc, const char *const *argv, const char *buff)
    16781677{
    16791678  char *lastrv = NULL, *newbuff;
     
    25952594}
    25962595
    2597 char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
     2596G_GNUC_WARN_UNUSED_RESULT char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
    25982597{
    25992598  const char *stylename;
     
    26392638}
    26402639
    2641 char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
     2640G_GNUC_WARN_UNUSED_RESULT char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
    26422641{
    26432642  owl_history *hist;
  • context.c

    rd4927a7 rd427f08  
    66
    77/* TODO: dependency from owl_context -> owl_window is annoying. */
    8 owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)
     8G_GNUC_WARN_UNUSED_RESULT owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)
    99{
    1010  owl_context *c;
  • dict.c

    r4c7c21f rd427f08  
    107107/* Doesn't free the value of the element, but does
    108108 * return it so the caller can free it. */
    109 void *owl_dict_remove_element(owl_dict *d, const char *k) {
     109G_GNUC_WARN_UNUSED_RESULT void *owl_dict_remove_element(owl_dict *d, const char *k)
     110{
    110111  int i;
    111112  int pos, found;
  • editcontext.c

    r4a41f16 rd427f08  
    88}
    99
    10 owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
     10G_GNUC_WARN_UNUSED_RESULT owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
    1111{
    1212  owl_context *ctx = owl_context_new(mode, owl_editwin_ref(e), keymap,
  • editwin.c

    r3b8a563 rd427f08  
    6161static const char *oe_copy_buf(owl_editwin *e, const char *buf, int len);
    6262static int oe_copy_region(owl_editwin *e);
    63 static char *oe_chunk(owl_editwin *e, int start, int end);
     63static G_GNUC_WARN_UNUSED_RESULT char *oe_chunk(owl_editwin *e, int start, int end);
    6464static void oe_destroy_cbdata(owl_editwin *e);
    6565static void oe_dirty(owl_editwin *e);
     
    7070#define WHITESPACE " \n\t"
    7171
    72 static owl_editwin *owl_editwin_allocate(void)
     72static G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_editwin_allocate(void)
    7373{
    7474  owl_editwin *e = g_new0(owl_editwin, 1);
     
    142142}
    143143
    144 owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
     144G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
    145145{
    146146  owl_editwin *e = owl_editwin_allocate();
     
    13691369}
    13701370
    1371 char *owl_editwin_get_region(owl_editwin *e)
     1371G_GNUC_WARN_UNUSED_RESULT char *owl_editwin_get_region(owl_editwin *e)
    13721372{
    13731373  int start, end;
     
    13881388}
    13891389
    1390 static char *oe_chunk(owl_editwin *e, int start, int end)
     1390static G_GNUC_WARN_UNUSED_RESULT char *oe_chunk(owl_editwin *e, int start, int end)
    13911391{
    13921392  char *p;
  • filter.c

    re56303f rd427f08  
    200200
    201201
    202 char* owl_filter_print(const owl_filter *f)
     202char G_GNUC_WARN_UNUSED_RESULT *owl_filter_print(const owl_filter *f)
    203203{
    204204  GString *out = g_string_new("");
  • fmtext.c

    r7b4f3be rd427f08  
    171171 * freeing the return
    172172 */
    173 char *owl_fmtext_print_plain(const owl_fmtext *f)
     173char G_GNUC_WARN_UNUSED_RESULT *owl_fmtext_print_plain(const owl_fmtext *f)
    174174{
    175175  return owl_strip_format_chars(f->buff->str);
  • functions.c

    r58f4fb2 rd427f08  
    1414#include "filterproc.h"
    1515
    16 char *owl_function_command(const char *cmdbuff)
     16G_GNUC_WARN_UNUSED_RESULT char *owl_function_command(const char *cmdbuff)
    1717{
    1818  owl_function_debugmsg("executing command: %s", cmdbuff);
     
    2121}
    2222
    23 char *owl_function_command_argv(const char *const *argv, int argc)
     23G_GNUC_WARN_UNUSED_RESULT char *owl_function_command_argv(const char *const *argv, int argc)
    2424{
    2525  return owl_cmddict_execute_argv(owl_global_get_cmddict(&g),
     
    9595}
    9696
    97 char *owl_function_style_describe(const char *name) {
     97G_GNUC_WARN_UNUSED_RESULT char *owl_function_style_describe(const char *name)
     98{
    9899  const char *desc;
    99100  char *s;
     
    111112}
    112113
    113 char *owl_function_cmd_describe(const char *name)
     114G_GNUC_WARN_UNUSED_RESULT char *owl_function_cmd_describe(const char *name)
    114115{
    115116  const owl_cmd *cmd = owl_cmddict_find(owl_global_get_cmddict(&g), name);
     
    249250 * owl_global_messagequeue_addmsg() for that.
    250251 */
    251 owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)
     252G_GNUC_WARN_UNUSED_RESULT owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)
    252253{
    253254  owl_message *m;
     
    270271 * owl_global_messagequeue_addmsg() for that.
    271272 */
    272 owl_message *owl_function_make_outgoing_loopback(const char *body)
     273G_GNUC_WARN_UNUSED_RESULT owl_message *owl_function_make_outgoing_loopback(const char *body)
    273274{
    274275  owl_message *m;
     
    18991900}
    19001901
    1901 owl_editwin *owl_function_start_question(const char *line)
     1902G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_function_start_question(const char *line)
    19021903{
    19031904  owl_editwin *tw;
     
    19141915}
    19151916
    1916 owl_editwin *owl_function_start_password(const char *line)
     1917G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_function_start_password(const char *line)
    19171918{
    19181919  owl_editwin *tw;
     
    19311932}
    19321933
    1933 char *owl_function_exec(int argc, const char *const *argv, const char *buff, int type)
     1934G_GNUC_WARN_UNUSED_RESULT char *owl_function_exec(int argc, const char *const *argv, const char *buff, int type)
    19341935{
    19351936  /* if type == 1 display in a popup
     
    19741975}
    19751976
    1976 char *owl_function_perl(int argc, const char *const *argv, const char *buff, int type)
     1977G_GNUC_WARN_UNUSED_RESULT char *owl_function_perl(int argc, const char *const *argv, const char *buff, int type)
    19771978{
    19781979  /* if type == 1 display in a popup
     
    21442145 * Returns the name of the negated filter, which the caller must free.
    21452146 */
    2146 char *owl_function_create_negative_filter(const char *filtername)
     2147G_GNUC_WARN_UNUSED_RESULT char *owl_function_create_negative_filter(const char *filtername)
    21472148{
    21482149  char *newname;
     
    22412242 * If 'related' is nonzero, encompass unclasses and .d classes as well.
    22422243 */
    2243 char *owl_function_classinstfilt(const char *c, const char *i, int related)
     2244G_GNUC_WARN_UNUSED_RESULT char *owl_function_classinstfilt(const char *c, const char *i, int related)
    22442245{
    22452246  owl_filter *f;
     
    23282329 * the filter, which the caller must free.
    23292330 */
    2330 char *owl_function_zuserfilt(const char *longuser)
     2331G_GNUC_WARN_UNUSED_RESULT char *owl_function_zuserfilt(const char *longuser)
    23312332{
    23322333  owl_filter *f;
     
    23742375 * Returns the name of the filter, which the caller must free.
    23752376 */
    2376 char *owl_function_aimuserfilt(const char *user)
     2377G_GNUC_WARN_UNUSED_RESULT char *owl_function_aimuserfilt(const char *user)
    23772378{
    23782379  owl_filter *f;
     
    24122413}
    24132414
    2414 char *owl_function_typefilt(const char *type)
     2415G_GNUC_WARN_UNUSED_RESULT char *owl_function_typefilt(const char *type)
    24152416{
    24162417  owl_filter *f;
     
    24682469}
    24692470
    2470 static char *owl_function_smartfilter_cc(const owl_message *m) {
     2471static G_GNUC_WARN_UNUSED_RESULT char *owl_function_smartfilter_cc(const owl_message *m)
     2472{
    24712473  const char *ccs;
    24722474  char *ccs_quoted;
     
    25192521 *    name to the AIM conversation with that user
    25202522 */
    2521 char *owl_function_smartfilter(int type, int invert_related)
     2523G_GNUC_WARN_UNUSED_RESULT char *owl_function_smartfilter(int type, int invert_related)
    25222524{
    25232525  const owl_view *v;
     
    28582860}
    28592861
    2860 char *owl_function_keymap_summary(const char *name)
     2862G_GNUC_WARN_UNUSED_RESULT char *owl_function_keymap_summary(const char *name)
    28612863{
    28622864  const owl_keymap *km
     
    29722974/* strips formatting from ztext and returns the unformatted text.
    29732975 * caller is responsible for freeing. */
    2974 char *owl_function_ztext_stylestrip(const char *zt)
     2976G_GNUC_WARN_UNUSED_RESULT char *owl_function_ztext_stylestrip(const char *zt)
    29752977{
    29762978  owl_fmtext fm;
  • global.c

    raa69c1e rd427f08  
    173173/* Pops the current context from the context stack and returns it. Caller is
    174174 * responsible for freeing. */
    175 owl_context *owl_global_pop_context_no_delete(owl_global *g) {
     175G_GNUC_WARN_UNUSED_RESULT owl_context *owl_global_pop_context_no_delete(owl_global *g)
     176{
    176177  owl_context *c;
    177178  if (!g->context_stack)
     
    725726 * necessary.
    726727 */
    727 owl_message *owl_global_messagequeue_popmsg(owl_global *g)
     728owl_message G_GNUC_WARN_UNUSED_RESULT *owl_global_messagequeue_popmsg(owl_global *g)
    728729{
    729730  owl_message *out;
  • keybinding.c

    r3b8a563 rd427f08  
    1414
    1515/* sets up a new keybinding for a command */
    16 owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
     16G_GNUC_WARN_UNUSED_RESULT owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
    1717{
    1818  owl_keybinding *kb = g_new(owl_keybinding, 1);
     
    8585}
    8686
    87 char *owl_keybinding_stack_tostring(int *j, int len)
     87G_GNUC_WARN_UNUSED_RESULT char *owl_keybinding_stack_tostring(int *j, int len)
    8888{
    8989  GString *string;
     
    100100}
    101101
    102 char *owl_keybinding_tostring(const owl_keybinding *kb)
     102G_GNUC_WARN_UNUSED_RESULT char *owl_keybinding_tostring(const owl_keybinding *kb)
    103103{
    104104  return owl_keybinding_stack_tostring(kb->keys, kb->len);
  • keymap.c

    r4c7c21f rd427f08  
    5151    }
    5252  }
    53   return owl_list_append_element(&km->bindings, kb); 
    54 
     53  owl_list_append_element(&km->bindings, kb);
     54  return 0;
    5555}
    5656
     
    8080
    8181/* returns a summary line describing this keymap.  the caller must free. */
    82 char *owl_keymap_summary(const owl_keymap *km)
     82G_GNUC_WARN_UNUSED_RESULT char *owl_keymap_summary(const owl_keymap *km)
    8383{
    8484  if (!km || !km->name || !km->desc) return NULL;
  • keypress.c

    rd07af84 rd427f08  
    129129/* OWL_META is definied in owl.h */
    130130
    131 char *owl_keypress_tostring(int j, int esc)
     131char G_GNUC_WARN_UNUSED_RESULT *owl_keypress_tostring(int j, int esc)
    132132{
    133133  GString *kb;
  • list.c

    rfda61d3 rd427f08  
    5353}
    5454
    55 int owl_list_append_element(owl_list *l, void *element)
     55void owl_list_append_element(owl_list *l, void *element)
    5656{
    57   return owl_list_insert_element(l, l->size, element);
     57  owl_list_insert_element(l, l->size, element);
    5858}
    5959
    60 int owl_list_prepend_element(owl_list *l, void *element)
     60void owl_list_prepend_element(owl_list *l, void *element)
    6161{
    62   return owl_list_insert_element(l, 0, element);
     62  owl_list_insert_element(l, 0, element);
    6363}
    6464
  • logging.c

    rcc305b5 rd427f08  
    8080}
    8181
    82 char *owl_log_zephyr(const owl_message *m) {
     82G_GNUC_WARN_UNUSED_RESULT char *owl_log_zephyr(const owl_message *m)
     83{
    8384    char *tmp = NULL;
    8485    GString *buffer = NULL;
     
    103104}
    104105
    105 char *owl_log_aim(const owl_message *m) {
     106G_GNUC_WARN_UNUSED_RESULT char *owl_log_aim(const owl_message *m)
     107{
    106108    GString *buffer = NULL;
    107109    buffer = g_string_new("");
     
    120122}
    121123
    122 char *owl_log_jabber(const owl_message *m) {
     124G_GNUC_WARN_UNUSED_RESULT char *owl_log_jabber(const owl_message *m)
     125{
    123126    GString *buffer = NULL;
    124127    buffer = g_string_new("");
     
    132135}
    133136
    134 char *owl_log_generic(const owl_message *m) {
     137G_GNUC_WARN_UNUSED_RESULT char *owl_log_generic(const owl_message *m)
     138{
    135139    GString *buffer;
    136140    buffer = g_string_new("");
  • message.c

    r259e60a8 rd427f08  
    580580
    581581/* caller must free return value. */
    582 char *owl_message_get_cc(const owl_message *m)
     582G_GNUC_WARN_UNUSED_RESULT char *owl_message_get_cc(const owl_message *m)
    583583{
    584584  const char *cur;
     
    597597
    598598/* caller must free return value */
    599 GList *owl_message_get_cc_without_recipient(const owl_message *m)
     599G_GNUC_WARN_UNUSED_RESULT GList *owl_message_get_cc_without_recipient(const owl_message *m)
    600600{
    601601  char *cc, *shortuser, *recip;
  • messagelist.c

    r66a8cd6 rd427f08  
    4242}
    4343
    44 int owl_messagelist_append_element(owl_messagelist *ml, void *element)
     44void owl_messagelist_append_element(owl_messagelist *ml, void *element)
    4545{
    46   return(owl_list_append_element(&(ml->list), element));
     46  owl_list_append_element(&ml->list, element);
    4747}
    4848
  • owl.h

    raa69c1e rd427f08  
    251251                                 * WARNING:  this approach is hard to make
    252252                                 * thread-safe... */
    253   char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
     253  char G_GNUC_WARN_UNUSED_RESULT *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
    254254                                /* converts val to a string;
    255255                                 * caller must free the result */
     
    313313 
    314314  /* These don't take any context */
    315   char *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff); 
     315  char G_GNUC_WARN_UNUSED_RESULT *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff);
    316316                                /* takes argv and the full command as buff.
    317317                                 * caller must free return value if !NULL */
     
    320320
    321321  /* The following also take the active context if it's valid */
    322   char *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff); 
     322  char G_GNUC_WARN_UNUSED_RESULT *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff);
    323323                                /* takes argv and the full command as buff.
    324324                                 * caller must free return value if !NULL */
  • perlconfig.c

    rbcde7926 rd427f08  
    2323
    2424
    25 SV *owl_new_sv(const char * str)
     25G_GNUC_WARN_UNUSED_RESULT SV *owl_new_sv(const char * str)
    2626{
    2727  SV *ret = newSVpv(str, 0);
     
    3636}
    3737
    38 AV *owl_new_av(const owl_list *l, SV *(*to_sv)(const void *))
     38G_GNUC_WARN_UNUSED_RESULT AV *owl_new_av(const owl_list *l, SV *(*to_sv)(const void *))
    3939{
    4040  AV *ret;
     
    5252}
    5353
    54 HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))
     54G_GNUC_WARN_UNUSED_RESULT HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))
    5555{
    5656  HV *ret;
     
    7575}
    7676
    77 SV *owl_perlconfig_message2hashref(const owl_message *m)
     77G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_message2hashref(const owl_message *m)
    7878{
    7979  HV *h, *stash;
     
    165165}
    166166
    167 SV *owl_perlconfig_curmessage2hashref(void)
     167G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_curmessage2hashref(void)
    168168{
    169169  int curmsg;
     
    183183   This has been somewhat addressed, but is still not lossless.
    184184 */
    185 owl_message * owl_perlconfig_hashref2message(SV *msg)
     185G_GNUC_WARN_UNUSED_RESULT owl_message *owl_perlconfig_hashref2message(SV *msg)
    186186{
    187187  owl_message * m;
     
    251251/* Calls in a scalar context, passing it a hash reference.
    252252   If return value is non-null, caller must free. */
    253 char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
     253G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
    254254{
    255255  dSP ;
     
    300300   If the return value is non-null, the caller must free it.
    301301 */
    302 char * owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char ** argv)
     302G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)
    303303{
    304304  dSP;
     
    349349}
    350350
    351 
    352 char *owl_perlconfig_initperl(const char * file, int *Pargc, char ***Pargv, char *** Penv)
     351/* caller must free result, if not NULL */
     352G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv)
    353353{
    354354  int ret;
     
    436436
    437437/* caller is responsible for freeing returned string */
    438 char *owl_perlconfig_execute(const char *line)
     438G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_execute(const char *line)
    439439{
    440440  STRLEN len;
     
    505505}
    506506
    507 char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
     507/* caller must free the result */
     508G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
    508509{
    509510  int i, count;
  • popwin.c

    rddbbcffa rd427f08  
    11#include "owl.h"
    22
    3 owl_popwin *owl_popwin_new(void)
     3G_GNUC_WARN_UNUSED_RESULT owl_popwin *owl_popwin_new(void)
    44{
    55  owl_popwin *pw = g_new0(owl_popwin, 1);
  • regex.c

    rd4927a7 rd427f08  
    3939{
    4040  char *quoted;
     41  int ret;
    4142 
    42   quoted=owl_text_quote(string, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    43   owl_regex_create(re, quoted);
     43  quoted = owl_text_quote(string, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
     44  ret = owl_regex_create(re, quoted);
    4445  g_free(quoted);
    45   return(0);
     46  return ret;
    4647}
    4748
  • text.c

    r7865479 rd427f08  
    77/* Returns a copy of 'in' with each line indented 'n'
    88 * characters. Result must be freed with g_free. */
    9 char *owl_text_indent(const char *in, int n)
     9G_GNUC_WARN_UNUSED_RESULT char *owl_text_indent(const char *in, int n)
    1010{
    1111  const char *ptr1, *ptr2, *last;
     
    4848
    4949/* caller must free the return */
    50 char *owl_text_htmlstrip(const char *in)
     50G_GNUC_WARN_UNUSED_RESULT char *owl_text_htmlstrip(const char *in)
    5151{
    5252  const char *ptr1, *end, *ptr2, *ptr3;
     
    129129
    130130/* Caller must free return */
    131 char *owl_text_expand_tabs(const char *in)
     131G_GNUC_WARN_UNUSED_RESULT char *owl_text_expand_tabs(const char *in)
    132132{
    133133  int len = 0;
     
    188188
    189189/* caller must free the return */
    190 char *owl_text_wordwrap(const char *in, int col)
     190G_GNUC_WARN_UNUSED_RESULT char *owl_text_wordwrap(const char *in, int col)
    191191{
    192192  char *out;
     
    269269 * Caller must free returned string.
    270270 */
    271 char *owl_text_substitute(const char *in, const char *from, const char *to)
     271G_GNUC_WARN_UNUSED_RESULT char *owl_text_substitute(const char *in, const char *from, const char *to)
    272272{
    273273  char **split = g_strsplit(in, from, 0), *out;
     
    284284 * On success returns the string, on error returns NULL.
    285285 */
    286 char *owl_text_quote(const char *in, const char *toquote, const char *quotestr)
     286G_GNUC_WARN_UNUSED_RESULT char *owl_text_quote(const char *in, const char *toquote, const char *quotestr)
    287287{
    288288  int i, x, r, place, escape;
  • util.c

    r83a4af3 rd427f08  
    3535 * duplicate slashes are removed.  Caller must free the return.
    3636 */
    37 char *owl_util_makepath(const char *in)
     37G_GNUC_WARN_UNUSED_RESULT char *owl_util_makepath(const char *in)
    3838{
    3939  int i, j, x;
     
    102102   to -1, argv will be NULL and the caller does not need to free anything. The
    103103   returned vector is NULL-terminated. */
    104 char **owl_parseline(const char *line, int *argc)
     104G_GNUC_WARN_UNUSED_RESULT char **owl_parseline(const char *line, int *argc)
    105105{
    106106  GPtrArray *argv;
     
    245245}
    246246
    247 char *owl_string_build_quoted(const char *tmpl, ...)
     247G_GNUC_WARN_UNUSED_RESULT char *owl_string_build_quoted(const char *tmpl, ...)
    248248{
    249249  GString *buf = g_string_new("");
     
    257257/* Returns a quoted version of arg suitable for placing in a
    258258 * command-line. Result should be freed with g_free. */
    259 char *owl_arg_quote(const char *arg)
     259G_GNUC_WARN_UNUSED_RESULT char *owl_arg_quote(const char *arg)
    260260{
    261261  GString *buf = g_string_new("");;
     
    265265
    266266/* caller must free the return */
    267 char *owl_util_minutes_to_timestr(int in)
     267G_GNUC_WARN_UNUSED_RESULT char *owl_util_minutes_to_timestr(int in)
    268268{
    269269  int days, hours;
     
    331331
    332332/* Get the default tty name.  Caller must free the return */
    333 char *owl_util_get_default_tty(void)
     333G_GNUC_WARN_UNUSED_RESULT char *owl_util_get_default_tty(void)
    334334{
    335335  const char *tmp;
     
    353353 * return.
    354354 */
    355 char *owl_util_stripnewlines(const char *in)
     355G_GNUC_WARN_UNUSED_RESULT char *owl_util_stripnewlines(const char *in)
    356356{
    357357 
     
    384384 * Error conditions are the same as g_file_read_link.
    385385 */
    386 gchar *owl_util_recursive_resolve_link(const char *filename)
     386G_GNUC_WARN_UNUSED_RESULT gchar *owl_util_recursive_resolve_link(const char *filename)
    387387{
    388388  gchar *last_path = g_strdup(filename);
     
    511511   The caller is responsible for freeing the allocated string.
    512512*/
    513 char * owl_util_baseclass(const char * class)
     513G_GNUC_WARN_UNUSED_RESULT char *owl_util_baseclass(const char *class)
    514514{
    515515  char *start, *end;
     
    546546
    547547/* Strips format characters from a valid utf-8 string. Returns the
    548    empty string if 'in' does not validate. */
    549 char * owl_strip_format_chars(const char *in)
     548   empty string if 'in' does not validate.  Caller must free the return. */
     549G_GNUC_WARN_UNUSED_RESULT char *owl_strip_format_chars(const char *in)
    550550{
    551551  char *r;
     
    584584 * out characters in Unicode Plane 16, as we use that plane internally
    585585 * for formatting.
    586  */
    587 char * owl_validate_or_convert(const char *in)
     586 * Caller must free the return.
     587 */
     588G_GNUC_WARN_UNUSED_RESULT char *owl_validate_or_convert(const char *in)
    588589{
    589590  if (g_utf8_validate(in, -1, NULL)) {
     
    599600 * Validate 'in' as UTF-8, and either return a copy of it, or an empty
    600601 * string if it is invalid utf-8.
    601  */
    602 char * owl_validate_utf8(const char *in)
     602 * Caller must free the return.
     603 */
     604G_GNUC_WARN_UNUSED_RESULT char *owl_validate_utf8(const char *in)
    603605{
    604606  char *out;
     
    632634}
    633635
    634 char *owl_escape_highbit(const char *str)
     636/* caller must free the return */
     637G_GNUC_WARN_UNUSED_RESULT char *owl_escape_highbit(const char *str)
    635638{
    636639  GString *out = g_string_new("");
     
    695698
    696699/* Read the rest of the input available in fp into a string. */
    697 char *owl_slurp(FILE *fp)
     700G_GNUC_WARN_UNUSED_RESULT char *owl_slurp(FILE *fp)
    698701{
    699702  char *buf = NULL;
  • 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>");
  • viewwin.c

    r4fd211f rd427f08  
    1212 * will be used by the viewwin
    1313 */
    14 owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
     14G_GNUC_WARN_UNUSED_RESULT owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
    1515{
    1616  owl_viewwin *v = g_new0(owl_viewwin, 1);
     
    3434 * will be used by the viewwin
    3535 */
    36 owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
     36G_GNUC_WARN_UNUSED_RESULT owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
    3737{
    3838  char *text;
     
    237237}
    238238
    239 owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {
     239G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {
    240240  int lines, cols;
    241241  owl_editwin *cmdline;
  • window.c

    rf97c1a6 rd427f08  
    569569};
    570570
    571 GSource *owl_window_redraw_source_new(void) {
     571G_GNUC_WARN_UNUSED_RESULT GSource *owl_window_redraw_source_new(void)
     572{
    572573  GSource *source;
    573574  source = g_source_new(&redraw_funcs, sizeof(GSource));
  • zcrypt.c

    r5b197f7 rd427f08  
    5353} ZWRITEOPTIONS;
    5454
    55 char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
     55G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
    5656int ParseCryptSpec(const char *spec, const char **keyfile);
    57 char *BuildArgString(char **argv, int start, int end);
    58 char *read_keystring(const char *keyfile);
     57G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end);
     58G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile);
    5959
    6060int do_encrypt(int zephyr, const char *class, const char *instance,
     
    364364/* Build a space-separated string from argv from elements between start  *
    365365 * and end - 1.  malloc()'s the returned string. */
    366 char *BuildArgString(char **argv, int start, int end)
     366G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end)
    367367{
    368368  int len = 1;
     
    401401#define MAX_SEARCH 3
    402402/* Find the class/instance in the .crypt-table */
    403 char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)
     403G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)
    404404{
    405405  char *keyfile = NULL;
     
    579579}
    580580
    581 char *slurp_stdin(int ignoredot, int *length) {
     581G_GNUC_WARN_UNUSED_RESULT char *slurp_stdin(int ignoredot, int *length) {
    582582  char *buf;
    583583  char *inptr;
     
    611611}
    612612
    613 char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {
     613G_GNUC_WARN_UNUSED_RESULT char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {
    614614  char *buf;
    615615
     
    637637}
    638638
    639 char *read_keystring(const char *keyfile) {
     639G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile) {
    640640  char *keystring;
    641641  FILE *fkey = fopen(keyfile, "r");
  • zephyr.c

    re146cd7 rd427f08  
    524524 */
    525525#ifdef HAVE_LIBZEPHYR
    526 char *owl_zephyr_get_field(const ZNotice_t *n, int j)
     526G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(const ZNotice_t *n, int j)
    527527{
    528528  int i, count, save;
     
    552552}
    553553
    554 char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
     554G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
    555555{
    556556  int i, count, save;
     
    584584}
    585585#else
    586 char *owl_zephyr_get_field(void *n, int j)
     586G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(void *n, int j)
    587587{
    588588  return(g_strdup(""));
    589589}
    590 char *owl_zephyr_get_field_as_utf8(void *n, int j)
     590G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(void *n, int j)
    591591{
    592592  return owl_zephyr_get_field(n, j);
     
    621621 * caller must free the return
    622622 */
    623 char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)
     623G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)
    624624{
    625625#define OWL_NFIELDS     5
     
    942942#endif
    943943
    944 char *owl_zephyr_zlocate(const char *user, int auth)
     944G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_zlocate(const char *user, int auth)
    945945{
    946946#ifdef HAVE_LIBZEPHYR
     
    10421042
    10431043/* caller must free the return */
    1044 char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
     1044G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
    10451045{
    10461046  return g_strdup_printf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);
     
    11221122 * free the return.
    11231123 */
    1124 char *owl_zephyr_getsubs(void)
     1124G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_getsubs(void)
    11251125{
    11261126#ifdef HAVE_LIBZEPHYR
     
    12421242 * The caller must free the return
    12431243 */
    1244 char *short_zuser(const char *in)
     1244G_GNUC_WARN_UNUSED_RESULT char *short_zuser(const char *in)
    12451245{
    12461246  char *ptr = strrchr(in, '@');
     
    12541254 * The caller must free the return.
    12551255 */
    1256 char *long_zuser(const char *in)
     1256G_GNUC_WARN_UNUSED_RESULT char *long_zuser(const char *in)
    12571257{
    12581258  char *ptr = strrchr(in, '@');
     
    12821282 * caller must free the return.
    12831283 */
    1284 char *owl_zephyr_smartstripped_user(const char *in)
     1284G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_smartstripped_user(const char *in)
    12851285{
    12861286  char *slash, *dot, *realm, *out;
  • zwrite.c

    r3b8a563 rd427f08  
    55#include "owl.h"
    66
    7 owl_zwrite *owl_zwrite_new(const char *line)
     7G_GNUC_WARN_UNUSED_RESULT owl_zwrite *owl_zwrite_new(const char *line)
    88{
    99  owl_zwrite *z = g_new(owl_zwrite, 1);
     
    1515}
    1616
    17 int owl_zwrite_create_from_line(owl_zwrite *z, const char *line)
     17G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create_from_line(owl_zwrite *z, const char *line)
    1818{
    1919  int argc, badargs, myargc;
     
    321321
    322322/* Caller must free the result. */
    323 char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)
     323G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)
    324324{
    325325  if (z->realm[0]) {
     
    370370 * If not a CC, only the recip_index'th user will be replied to.
    371371 */
    372 char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)
     372G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)
    373373{
    374374  /* Match ordering in zwrite help. */
Note: See TracChangeset for help on using the changeset viewer.