Changeset d427f08 for functions.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
  • 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;
Note: See TracChangeset for help on using the changeset viewer.