Changeset 7dfe886


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.)
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • aim.c

    rdc1edbd r7dfe886  
    428428
    429429/* caller must free the return */
    430 char *owl_aim_normalize_screenname(const char *in)
     430G_GNUC_WARN_UNUSED_RESULT char *owl_aim_normalize_screenname(const char *in)
    431431{
    432432  char *out;
  • cmd.c

    raad166a r7dfe886  
    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

    r117c21c r7dfe886  
    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[] = {
     
    10411041  };
    10421042
    1043   int ret = owl_cmddict_add_from_list(cd, commands_to_init);
     1043  owl_cmddict_add_from_list(cd, commands_to_init);
    10441044  owl_cmd *cmd;
    10451045  for (cmd = commands_to_init; cmd->name != NULL; cmd++)
    10461046    owl_cmd_cleanup(cmd);
    1047   return ret;
    10481047}
    10491048
     
    13751374}
    13761375
    1377 char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
     1376G_GNUC_WARN_UNUSED_RESULT char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
    13781377{
    13791378  char *filtname = NULL;
     
    14151414}
    14161415
    1417 char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
     1416G_GNUC_WARN_UNUSED_RESULT char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
    14181417{
    14191418  if(argc != 1)
     
    16461645
    16471646
    1648 char *owl_command_exec(int argc, const char *const *argv, const char *buff)
     1647G_GNUC_WARN_UNUSED_RESULT char *owl_command_exec(int argc, const char *const *argv, const char *buff)
    16491648{
    16501649  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_RETURN);
    16511650}
    16521651
    1653 char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
     1652G_GNUC_WARN_UNUSED_RESULT char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
    16541653{
    16551654  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_POPUP);
    16561655}
    16571656
    1658 char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
     1657G_GNUC_WARN_UNUSED_RESULT char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
    16591658{
    16601659  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_ADMINMSG);
    16611660}
    16621661
    1663 char *owl_command_perl(int argc, const char *const *argv, const char *buff)
     1662G_GNUC_WARN_UNUSED_RESULT char *owl_command_perl(int argc, const char *const *argv, const char *buff)
    16641663{
    16651664  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_RETURN);
    16661665}
    16671666
    1668 char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
     1667G_GNUC_WARN_UNUSED_RESULT char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
    16691668{
    16701669  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_POPUP);
    16711670}
    16721671
    1673 char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
     1672G_GNUC_WARN_UNUSED_RESULT char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
    16741673{
    16751674  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_ADMINMSG);
    16761675}
    16771676
    1678 char *owl_command_multi(int argc, const char *const *argv, const char *buff)
     1677G_GNUC_WARN_UNUSED_RESULT char *owl_command_multi(int argc, const char *const *argv, const char *buff)
    16791678{
    16801679  char *lastrv = NULL, *newbuff;
     
    25982597}
    25992598
    2600 char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
     2599G_GNUC_WARN_UNUSED_RESULT char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
    26012600{
    26022601  const char *stylename;
     
    26422641}
    26432642
    2644 char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
     2643G_GNUC_WARN_UNUSED_RESULT char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
    26452644{
    26462645  owl_history *hist;
  • context.c

    rd4927a7 r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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

    r259e60a8 r7dfe886  
    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),
     
    125125}
    126126
    127 char *owl_function_style_describe(const char *name) {
     127G_GNUC_WARN_UNUSED_RESULT char *owl_function_style_describe(const char *name)
     128{
    128129  const char *desc;
    129130  char *s;
     
    141142}
    142143
    143 char *owl_function_cmd_describe(const char *name)
     144G_GNUC_WARN_UNUSED_RESULT char *owl_function_cmd_describe(const char *name)
    144145{
    145146  const owl_cmd *cmd = owl_cmddict_find(owl_global_get_cmddict(&g), name);
     
    279280 * owl_global_messagequeue_addmsg() for that.
    280281 */
    281 owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)
     282G_GNUC_WARN_UNUSED_RESULT owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)
    282283{
    283284  owl_message *m;
     
    300301 * owl_global_messagequeue_addmsg() for that.
    301302 */
    302 owl_message *owl_function_make_outgoing_loopback(const char *body)
     303G_GNUC_WARN_UNUSED_RESULT owl_message *owl_function_make_outgoing_loopback(const char *body)
    303304{
    304305  owl_message *m;
     
    19291930}
    19301931
    1931 owl_editwin *owl_function_start_question(const char *line)
     1932G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_function_start_question(const char *line)
    19321933{
    19331934  owl_editwin *tw;
     
    19441945}
    19451946
    1946 owl_editwin *owl_function_start_password(const char *line)
     1947G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_function_start_password(const char *line)
    19471948{
    19481949  owl_editwin *tw;
     
    19611962}
    19621963
    1963 char *owl_function_exec(int argc, const char *const *argv, const char *buff, int type)
     1964G_GNUC_WARN_UNUSED_RESULT char *owl_function_exec(int argc, const char *const *argv, const char *buff, int type)
    19641965{
    19651966  /* if type == 1 display in a popup
     
    20042005}
    20052006
    2006 char *owl_function_perl(int argc, const char *const *argv, const char *buff, int type)
     2007G_GNUC_WARN_UNUSED_RESULT char *owl_function_perl(int argc, const char *const *argv, const char *buff, int type)
    20072008{
    20082009  /* if type == 1 display in a popup
     
    21742175 * Returns the name of the negated filter, which the caller must free.
    21752176 */
    2176 char *owl_function_create_negative_filter(const char *filtername)
     2177G_GNUC_WARN_UNUSED_RESULT char *owl_function_create_negative_filter(const char *filtername)
    21772178{
    21782179  char *newname;
     
    22712272 * If 'related' is nonzero, encompass unclasses and .d classes as well.
    22722273 */
    2273 char *owl_function_classinstfilt(const char *c, const char *i, int related)
     2274G_GNUC_WARN_UNUSED_RESULT char *owl_function_classinstfilt(const char *c, const char *i, int related)
    22742275{
    22752276  owl_filter *f;
     
    23582359 * the filter, which the caller must free.
    23592360 */
    2360 char *owl_function_zuserfilt(const char *longuser)
     2361G_GNUC_WARN_UNUSED_RESULT char *owl_function_zuserfilt(const char *longuser)
    23612362{
    23622363  owl_filter *f;
     
    24042405 * Returns the name of the filter, which the caller must free.
    24052406 */
    2406 char *owl_function_aimuserfilt(const char *user)
     2407G_GNUC_WARN_UNUSED_RESULT char *owl_function_aimuserfilt(const char *user)
    24072408{
    24082409  owl_filter *f;
     
    24422443}
    24432444
    2444 char *owl_function_typefilt(const char *type)
     2445G_GNUC_WARN_UNUSED_RESULT char *owl_function_typefilt(const char *type)
    24452446{
    24462447  owl_filter *f;
     
    24982499}
    24992500
    2500 static char *owl_function_smartfilter_cc(const owl_message *m) {
     2501static G_GNUC_WARN_UNUSED_RESULT char *owl_function_smartfilter_cc(const owl_message *m)
     2502{
    25012503  const char *ccs;
    25022504  char *ccs_quoted;
     
    25492551 *    name to the AIM conversation with that user
    25502552 */
    2551 char *owl_function_smartfilter(int type, int invert_related)
     2553G_GNUC_WARN_UNUSED_RESULT char *owl_function_smartfilter(int type, int invert_related)
    25522554{
    25532555  const owl_view *v;
     
    28882890}
    28892891
    2890 char *owl_function_keymap_summary(const char *name)
     2892G_GNUC_WARN_UNUSED_RESULT char *owl_function_keymap_summary(const char *name)
    28912893{
    28922894  const owl_keymap *km
     
    30023004/* strips formatting from ztext and returns the unformatted text.
    30033005 * caller is responsible for freeing. */
    3004 char *owl_function_ztext_stylestrip(const char *zt)
     3006G_GNUC_WARN_UNUSED_RESULT char *owl_function_ztext_stylestrip(const char *zt)
    30053007{
    30063008  owl_fmtext fm;
  • global.c

    rf97c1a6 r7dfe886  
    175175/* Pops the current context from the context stack and returns it. Caller is
    176176 * responsible for freeing. */
    177 owl_context *owl_global_pop_context_no_delete(owl_global *g) {
     177G_GNUC_WARN_UNUSED_RESULT owl_context *owl_global_pop_context_no_delete(owl_global *g)
     178{
    178179  owl_context *c;
    179180  if (!g->context_stack)
     
    727728 * necessary.
    728729 */
    729 owl_message *owl_global_messagequeue_popmsg(owl_global *g)
     730owl_message G_GNUC_WARN_UNUSED_RESULT *owl_global_messagequeue_popmsg(owl_global *g)
    730731{
    731732  owl_message *out;
  • keybinding.c

    r3b8a563 r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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

    r24a791f r7dfe886  
    255255                                 * WARNING:  this approach is hard to make
    256256                                 * thread-safe... */
    257   char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
     257  char G_GNUC_WARN_UNUSED_RESULT *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
    258258                                /* converts val to a string;
    259259                                 * caller must free the result */
     
    317317 
    318318  /* These don't take any context */
    319   char *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff); 
     319  char G_GNUC_WARN_UNUSED_RESULT *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff);
    320320                                /* takes argv and the full command as buff.
    321321                                 * caller must free return value if !NULL */
     
    324324
    325325  /* The following also take the active context if it's valid */
    326   char *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff); 
     326  char G_GNUC_WARN_UNUSED_RESULT *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff);
    327327                                /* takes argv and the full command as buff.
    328328                                 * caller must free return value if !NULL */
  • perlconfig.c

    ra9237aa r7dfe886  
    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;
     
    250250/* Calls in a scalar context, passing it a hash reference.
    251251   If return value is non-null, caller must free. */
    252 char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
     252G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
    253253{
    254254  dSP ;
     
    299299   If the return value is non-null, the caller must free it.
    300300 */
    301 char * owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char ** argv)
     301G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)
    302302{
    303303  dSP;
     
    348348}
    349349
    350 
    351 char *owl_perlconfig_initperl(const char * file, int *Pargc, char ***Pargv, char *** Penv)
     350/* caller must free result, if not NULL */
     351G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv)
    352352{
    353353  int ret;
     
    435435
    436436/* caller is responsible for freeing returned string */
    437 char *owl_perlconfig_execute(const char *line)
     437G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_execute(const char *line)
    438438{
    439439  STRLEN len;
     
    504504}
    505505
    506 char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
     506/* caller must free the result */
     507G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
    507508{
    508509  int i, count;
  • popwin.c

    rddbbcffa r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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

    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>");
  • viewwin.c

    r4fd211f r7dfe886  
    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 r7dfe886  
    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 r7dfe886  
    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

    rb848e30 r7dfe886  
    521521 */
    522522#ifdef HAVE_LIBZEPHYR
    523 char *owl_zephyr_get_field(const ZNotice_t *n, int j)
     523G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(const ZNotice_t *n, int j)
    524524{
    525525  int i, count, save;
     
    549549}
    550550
    551 char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
     551G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
    552552{
    553553  int i, count, save;
     
    581581}
    582582#else
    583 char *owl_zephyr_get_field(void *n, int j)
     583G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(void *n, int j)
    584584{
    585585  return(g_strdup(""));
    586586}
    587 char *owl_zephyr_get_field_as_utf8(void *n, int j)
     587G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(void *n, int j)
    588588{
    589589  return owl_zephyr_get_field(n, j);
     
    618618 * caller must free the return
    619619 */
    620 char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)
     620G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)
    621621{
    622622#define OWL_NFIELDS     5
     
    939939#endif
    940940
    941 char *owl_zephyr_zlocate(const char *user, int auth)
     941G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_zlocate(const char *user, int auth)
    942942{
    943943#ifdef HAVE_LIBZEPHYR
     
    10391039
    10401040/* caller must free the return */
    1041 char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
     1041G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
    10421042{
    10431043  return g_strdup_printf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);
     
    11191119 * free the return.
    11201120 */
    1121 char *owl_zephyr_getsubs(void)
     1121G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_getsubs(void)
    11221122{
    11231123#ifdef HAVE_LIBZEPHYR
     
    12391239 * The caller must free the return
    12401240 */
    1241 char *short_zuser(const char *in)
     1241G_GNUC_WARN_UNUSED_RESULT char *short_zuser(const char *in)
    12421242{
    12431243  char *ptr = strrchr(in, '@');
     
    12511251 * The caller must free the return.
    12521252 */
    1253 char *long_zuser(const char *in)
     1253G_GNUC_WARN_UNUSED_RESULT char *long_zuser(const char *in)
    12541254{
    12551255  char *ptr = strrchr(in, '@');
     
    12791279 * caller must free the return.
    12801280 */
    1281 char *owl_zephyr_smartstripped_user(const char *in)
     1281G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_smartstripped_user(const char *in)
    12821282{
    12831283  char *slash, *dot, *realm, *out;
  • zwrite.c

    r3b8a563 r7dfe886  
    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.