diff options
author | Kevin P. Fleming <kpfleming@digium.com> | 2008-11-02 18:52:13 +0000 |
---|---|---|
committer | Kevin P. Fleming <kpfleming@digium.com> | 2008-11-02 18:52:13 +0000 |
commit | bd4eb070f3b292617be20bda069cac47df2f7495 (patch) | |
tree | a3750d996d41e35c5df34c29533dd7d9fdcaff24 /main | |
parent | 1e6864dd9d894db29ebc350b015e9eb58226a021 (diff) |
bring over all the fixes for the warnings found by gcc 4.3.x from the 1.4 branch, and add the ones needed for all the new code here too
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@153616 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/ast_expr2f.c | 163 | ||||
-rw-r--r-- | main/asterisk.c | 49 | ||||
-rw-r--r-- | main/channel.c | 16 | ||||
-rw-r--r-- | main/db1-ast/hash/hash_page.c | 10 | ||||
-rw-r--r-- | main/file.c | 24 | ||||
-rw-r--r-- | main/http.c | 12 | ||||
-rw-r--r-- | main/logger.c | 4 | ||||
-rw-r--r-- | main/manager.c | 4 | ||||
-rw-r--r-- | main/utils.c | 7 |
9 files changed, 194 insertions, 95 deletions
diff --git a/main/ast_expr2f.c b/main/ast_expr2f.c index b6ab64e26..5999c73dc 100644 --- a/main/ast_expr2f.c +++ b/main/ast_expr2f.c @@ -11,7 +11,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 33 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -33,7 +33,7 @@ /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ -#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. @@ -56,7 +56,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -87,6 +86,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -96,11 +97,12 @@ typedef unsigned int flex_uint32_t; #else /* ! __cplusplus */ -#if __STDC__ +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) #define YY_USE_CONST -#endif /* __STDC__ */ +#endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST @@ -136,8 +138,6 @@ typedef void* yyscan_t; #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) #define yy_flex_debug yyg->yy_flex_debug_r -int ast_yylex_init (yyscan_t* scanner); - /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. @@ -195,14 +195,9 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T -typedef unsigned int yy_size_t; +typedef size_t yy_size_t; #endif #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -2406,7 +2401,7 @@ int ast_yyget_column(yyscan_t yyscanner); static int curlycount = 0; static char *expr2_token_subst(const char *mess); -#line 2410 "ast_expr2f.c" +#line 2403 "ast_expr2f.c" #define INITIAL 0 #define var 1 @@ -2470,6 +2465,10 @@ static int yy_init_globals (yyscan_t yyscanner ); # define yylloc yyg->yylloc_r +int ast_yylex_init (yyscan_t* scanner); + +int ast_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); + /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ @@ -2549,7 +2548,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -2629,10 +2628,10 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 127 "ast_expr2.fl" +#line 125 "ast_expr2.fl" -#line 2636 "ast_expr2f.c" +#line 2633 "ast_expr2f.c" yylval = yylval_param; @@ -2715,132 +2714,132 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 129 "ast_expr2.fl" +#line 127 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_OR;} YY_BREAK case 2: YY_RULE_SETUP -#line 130 "ast_expr2.fl" +#line 128 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_AND;} YY_BREAK case 3: YY_RULE_SETUP -#line 131 "ast_expr2.fl" +#line 129 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_EQ;} YY_BREAK case 4: YY_RULE_SETUP -#line 132 "ast_expr2.fl" +#line 130 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_OR;} YY_BREAK case 5: YY_RULE_SETUP -#line 133 "ast_expr2.fl" +#line 131 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_AND;} YY_BREAK case 6: YY_RULE_SETUP -#line 134 "ast_expr2.fl" +#line 132 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_EQ;} YY_BREAK case 7: YY_RULE_SETUP -#line 135 "ast_expr2.fl" +#line 133 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_EQTILDE;} YY_BREAK case 8: YY_RULE_SETUP -#line 136 "ast_expr2.fl" +#line 134 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_TILDETILDE;} YY_BREAK case 9: YY_RULE_SETUP -#line 137 "ast_expr2.fl" +#line 135 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_GT;} YY_BREAK case 10: YY_RULE_SETUP -#line 138 "ast_expr2.fl" +#line 136 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_LT;} YY_BREAK case 11: YY_RULE_SETUP -#line 139 "ast_expr2.fl" +#line 137 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_GE;} YY_BREAK case 12: YY_RULE_SETUP -#line 140 "ast_expr2.fl" +#line 138 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_LE;} YY_BREAK case 13: YY_RULE_SETUP -#line 141 "ast_expr2.fl" +#line 139 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_NE;} YY_BREAK case 14: YY_RULE_SETUP -#line 142 "ast_expr2.fl" +#line 140 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_PLUS;} YY_BREAK case 15: YY_RULE_SETUP -#line 143 "ast_expr2.fl" +#line 141 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_COMMA;} YY_BREAK case 16: YY_RULE_SETUP -#line 144 "ast_expr2.fl" +#line 142 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_MINUS;} YY_BREAK case 17: YY_RULE_SETUP -#line 145 "ast_expr2.fl" +#line 143 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_MULT;} YY_BREAK case 18: YY_RULE_SETUP -#line 146 "ast_expr2.fl" +#line 144 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_DIV;} YY_BREAK case 19: YY_RULE_SETUP -#line 147 "ast_expr2.fl" +#line 145 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_MOD;} YY_BREAK case 20: YY_RULE_SETUP -#line 148 "ast_expr2.fl" +#line 146 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_COND;} YY_BREAK case 21: YY_RULE_SETUP -#line 149 "ast_expr2.fl" +#line 147 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_COMPL;} YY_BREAK case 22: YY_RULE_SETUP -#line 150 "ast_expr2.fl" +#line 148 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_COLON;} YY_BREAK case 23: YY_RULE_SETUP -#line 151 "ast_expr2.fl" +#line 149 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_COLONCOLON;} YY_BREAK case 24: YY_RULE_SETUP -#line 152 "ast_expr2.fl" +#line 150 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_LP;} YY_BREAK case 25: YY_RULE_SETUP -#line 153 "ast_expr2.fl" +#line 151 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_RP;} YY_BREAK case 26: YY_RULE_SETUP -#line 154 "ast_expr2.fl" +#line 152 "ast_expr2.fl" { /* gather the contents of ${} expressions, with trailing stuff, * into a single TOKEN. @@ -2853,24 +2852,24 @@ YY_RULE_SETUP YY_BREAK case 27: YY_RULE_SETUP -#line 164 "ast_expr2.fl" +#line 162 "ast_expr2.fl" {} YY_BREAK case 28: /* rule 28 can match eol */ YY_RULE_SETUP -#line 165 "ast_expr2.fl" +#line 163 "ast_expr2.fl" {SET_COLUMNS; SET_STRING; return TOKEN;} YY_BREAK case 29: /* rule 29 can match eol */ YY_RULE_SETUP -#line 167 "ast_expr2.fl" +#line 165 "ast_expr2.fl" {/* what to do with eol */} YY_BREAK case 30: YY_RULE_SETUP -#line 168 "ast_expr2.fl" +#line 166 "ast_expr2.fl" { SET_COLUMNS; /* the original behavior of the expression parser was @@ -2883,7 +2882,7 @@ YY_RULE_SETUP case 31: /* rule 31 can match eol */ YY_RULE_SETUP -#line 177 "ast_expr2.fl" +#line 175 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; @@ -2893,7 +2892,7 @@ YY_RULE_SETUP case 32: /* rule 32 can match eol */ YY_RULE_SETUP -#line 184 "ast_expr2.fl" +#line 182 "ast_expr2.fl" { curlycount--; if (curlycount < 0) { @@ -2907,7 +2906,7 @@ YY_RULE_SETUP case 33: /* rule 33 can match eol */ YY_RULE_SETUP -#line 194 "ast_expr2.fl" +#line 192 "ast_expr2.fl" { curlycount++; yymore(); @@ -2915,7 +2914,7 @@ YY_RULE_SETUP YY_BREAK case 34: YY_RULE_SETUP -#line 200 "ast_expr2.fl" +#line 198 "ast_expr2.fl" { BEGIN(0); SET_COLUMNS; @@ -2926,7 +2925,7 @@ YY_RULE_SETUP case 35: /* rule 35 can match eol */ YY_RULE_SETUP -#line 207 "ast_expr2.fl" +#line 205 "ast_expr2.fl" { char c = yytext[yyleng-1]; BEGIN(0); @@ -2938,7 +2937,7 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 216 "ast_expr2.fl" +#line 214 "ast_expr2.fl" { curlycount = 0; BEGIN(var); @@ -2946,7 +2945,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(trail): -#line 222 "ast_expr2.fl" +#line 220 "ast_expr2.fl" { BEGIN(0); SET_COLUMNS; @@ -2957,10 +2956,10 @@ case YY_STATE_EOF(trail): YY_BREAK case 37: YY_RULE_SETUP -#line 230 "ast_expr2.fl" +#line 228 "ast_expr2.fl" ECHO; YY_BREAK -#line 2964 "ast_expr2f.c" +#line 2961 "ast_expr2f.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(var): yyterminate(); @@ -3217,6 +3216,14 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else ret_val = EOB_ACT_CONTINUE_SCAN; + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ast_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + yyg->yy_n_chars += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; @@ -3640,7 +3647,9 @@ static void ast_yyensure_buffer_stack (yyscan_t yyscanner) yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); - + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" ); + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); yyg->yy_buffer_stack_max = num_to_alloc; @@ -3658,6 +3667,8 @@ static void ast_yyensure_buffer_stack (yyscan_t yyscanner) (yyg->yy_buffer_stack, num_to_alloc * sizeof(struct yy_buffer_state*) , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -3976,6 +3987,42 @@ int ast_yylex_init(yyscan_t* ptr_yy_globals) return yy_init_globals ( *ptr_yy_globals ); } +/* ast_yylex_init_extra has the same functionality as ast_yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to ast_yyalloc in + * the yyextra field. + */ + +int ast_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + ast_yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) ast_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + ast_yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + static int yy_init_globals (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -4082,7 +4129,7 @@ void *ast_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 230 "ast_expr2.fl" +#line 228 "ast_expr2.fl" diff --git a/main/asterisk.c b/main/asterisk.c index 239acd7ff..37c84bd67 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -1218,8 +1218,11 @@ static void hup_handler(int num) if (restartnow) execvp(_argv[0], _argv); sig_flags.need_reload = 1; - if (sig_alert_pipe[1] != -1) - write(sig_alert_pipe[1], &a, sizeof(a)); + if (sig_alert_pipe[1] != -1) { + if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) { + fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno)); + } + } signal(num, hup_handler); } @@ -1434,8 +1437,11 @@ static void __quit_handler(int num) { int a = 0; sig_flags.need_quit = 1; - if (sig_alert_pipe[1] != -1) - write(sig_alert_pipe[1], &a, sizeof(a)); + if (sig_alert_pipe[1] != -1) { + if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) { + fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno)); + } + } /* There is no need to restore the signal handler here, since the app * is going to exit */ } @@ -1814,7 +1820,7 @@ static char *show_warranty(struct ast_cli_entry *e, int cmd, struct ast_cli_args return NULL; } - ast_cli(a->fd, warranty_lines); + ast_cli(a->fd, "%s", warranty_lines); return CLI_SUCCESS; } @@ -1851,7 +1857,7 @@ static char *show_license(struct ast_cli_entry *e, int cmd, struct ast_cli_args return NULL; } - ast_cli(a->fd, license_lines); + ast_cli(a->fd, "%s", license_lines); return CLI_SUCCESS; } @@ -1971,9 +1977,12 @@ static int ast_el_read_char(EditLine *editline, char *cp) } /* Write over the CLI prompt */ - if (!ast_opt_exec && !lastpos) - write(STDOUT_FILENO, "\r", 1); - write(STDOUT_FILENO, buf, res); + if (!ast_opt_exec && !lastpos) { + if (write(STDOUT_FILENO, "\r", 1) < 0) { + } + } + if (write(STDOUT_FILENO, buf, res) < 0) { + } if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (buf[res-2] == '\n'))) { *cp = CC_REFRESH; return(1); @@ -2416,7 +2425,7 @@ static int ast_el_read_history(char *filename) return ret; } -static void ast_remotecontrol(char * data) +static void ast_remotecontrol(char *data) { char buf[80]; int res; @@ -2430,12 +2439,17 @@ static void ast_remotecontrol(char * data) char *ebuf; int num = 0; - read(ast_consock, buf, sizeof(buf)); + if (read(ast_consock, buf, sizeof(buf)) < 0) { + ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno)); + return; + } if (data) { char prefix[] = "cli quit after "; char *tmp = alloca(strlen(data) + strlen(prefix) + 1); sprintf(tmp, "%s%s", prefix, data); - write(ast_consock, tmp, strlen(tmp) + 1); + if (write(ast_consock, tmp, strlen(tmp) + 1) < 0) { + ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno)); + } } stringp = buf; hostname = strsep(&stringp, "/"); @@ -2495,7 +2509,9 @@ static void ast_remotecontrol(char * data) /* Skip verbose lines */ if (*curline != 127) { not_written = 0; - write(STDOUT_FILENO, curline, nextline - curline); + if (write(STDOUT_FILENO, curline, nextline - curline) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } } curline = nextline; } while (!ast_strlen_zero(curline)); @@ -2825,7 +2841,8 @@ static void *monitor_sig_flags(void *unused) sig_flags.need_quit = 0; quit_handler(0, 0, 1, 0); } - read(sig_alert_pipe[0], &a, sizeof(a)); + if (read(sig_alert_pipe[0], &a, sizeof(a)) != sizeof(a)) { + } } return NULL; @@ -3265,7 +3282,9 @@ int main(int argc, char *argv[]) #if HAVE_WORKING_FORK if (ast_opt_always_fork || !ast_opt_no_fork) { #ifndef HAVE_SBIN_LAUNCHD - daemon(1, 0); + if (daemon(1, 0) < 0) { + ast_log(LOG_ERROR, "daemon() failed: %s\n", strerror(errno)); + } ast_mainpid = getpid(); /* Blindly re-write pid file since we are forking */ unlink(ast_config_AST_PID); diff --git a/main/channel.c b/main/channel.c index 6ace4c008..4174613ec 100644 --- a/main/channel.c +++ b/main/channel.c @@ -2272,8 +2272,11 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd) break; case AST_FRAME_VOICE: /* Write audio if appropriate */ - if (audiofd > -1) - write(audiofd, f->data.ptr, f->datalen); + if (audiofd > -1) { + if (write(audiofd, f->data.ptr, f->datalen) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } + } default: /* Ignore */ break; @@ -2420,7 +2423,9 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) goto done; } } - read(chan->alertpipe[0], &blah, sizeof(blah)); + if (read(chan->alertpipe[0], &blah, sizeof(blah)) < 0) { + ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno)); + } } if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD) { @@ -3887,7 +3892,10 @@ int ast_do_masquerade(struct ast_channel *original) AST_LIST_INSERT_TAIL(&original->readq, current, frame_list); if (original->alertpipe[1] > -1) { int poke = 0; - write(original->alertpipe[1], &poke, sizeof(poke)); + + if (write(original->alertpipe[1], &poke, sizeof(poke)) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } } } } diff --git a/main/db1-ast/hash/hash_page.c b/main/db1-ast/hash/hash_page.c index 737b97d32..52571c552 100644 --- a/main/db1-ast/hash/hash_page.c +++ b/main/db1-ast/hash/hash_page.c @@ -712,7 +712,8 @@ overflow_page(hashp) #define OVMSG "HASH: Out of overflow pages. Increase page size\n" if (offset > SPLITMASK) { if (++splitnum >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); + if (write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1) < 0) { + } return (0); } hashp->OVFL_POINT = splitnum; @@ -725,7 +726,8 @@ overflow_page(hashp) if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) { free_page++; if (free_page >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); + if (write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1) < 0) { + } return (0); } /* @@ -749,8 +751,8 @@ overflow_page(hashp) offset++; if (offset > SPLITMASK) { if (++splitnum >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, - sizeof(OVMSG) - 1); + if (write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1) < 0) { + } return (0); } hashp->OVFL_POINT = splitnum; diff --git a/main/file.c b/main/file.c index a9b36e7f5..f6bdd7cf5 100644 --- a/main/file.c +++ b/main/file.c @@ -249,11 +249,18 @@ static char *build_filename(const char *filename, const char *ext) if (!strcmp(ext, "wav49")) ext = "WAV"; - if (filename[0] == '/') - asprintf(&fn, "%s.%s", filename, ext); - else - asprintf(&fn, "%s/sounds/%s.%s", - ast_config_AST_DATA_DIR, filename, ext); + if (filename[0] == '/') { + if (asprintf(&fn, "%s.%s", filename, ext) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + fn = NULL; + } + } else { + if (asprintf(&fn, "%s/sounds/%s.%s", + ast_config_AST_DATA_DIR, filename, ext) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + fn = NULL; + } + } return fn; } @@ -1187,8 +1194,11 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, break; case AST_FRAME_VOICE: /* Write audio if appropriate */ - if (audiofd > -1) - write(audiofd, fr->data.ptr, fr->datalen); + if (audiofd > -1) { + if (write(audiofd, fr->data.ptr, fr->datalen) < 0) { + ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); + } + } default: /* Ignore all others */ break; diff --git a/main/http.c b/main/http.c index f7a1e18a0..0e59146a4 100644 --- a/main/http.c +++ b/main/http.c @@ -219,7 +219,9 @@ static struct ast_str *static_callback(struct ast_tcptls_session_instance *ser, ast_get_version(), buf, (int) st.st_size, mtype); while ((len = read(fd, buf, sizeof(buf))) > 0) { - fwrite(buf, 1, len, ser->f); + if (fwrite(buf, 1, len, ser->f) != len) { + ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); + } } close(fd); @@ -760,8 +762,12 @@ static void *httpd_helper_thread(void *data) if (tmp) { fprintf(ser->f, "Content-length: %d\r\n", contentlength); /* first write the header, then the body */ - fwrite(out->str, 1, (tmp + 4 - out->str), ser->f); - fwrite(tmp + 4, 1, contentlength, ser->f); + if (fwrite(out->str, 1, (tmp + 4 - out->str), ser->f) != tmp + 4 - out->str) { + ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); + } + if (fwrite(tmp + 4, 1, contentlength, ser->f) != contentlength ) { + ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno)); + } } } ast_free(out); diff --git a/main/logger.c b/main/logger.c index d09d8271f..4e3a2b73c 100644 --- a/main/logger.c +++ b/main/logger.c @@ -576,7 +576,9 @@ static int rotate_file(const char *filename) char buf[512]; pbx_builtin_setvar_helper(c, "filename", filename); pbx_substitute_variables_helper(c, exec_after_rotate, buf, sizeof(buf)); - system(buf); + if (system(buf) < 0) { + ast_log(LOG_WARNING, "system() failed for '%s': %s\n", buf, strerror(errno)); + } ast_channel_free(c); } return res; diff --git a/main/manager.c b/main/manager.c index 71e97b8f9..e7fd926f0 100644 --- a/main/manager.c +++ b/main/manager.c @@ -2212,7 +2212,9 @@ static int action_command(struct mansession *s, const struct message *m) final_buf = ast_calloc(1, l + 1); if (buf) { lseek(fd, 0, SEEK_SET); - read(fd, buf, l); + if (read(fd, buf, l) < 0) { + ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno)); + } buf[l] = '\0'; if (final_buf) { term_strip(final_buf, buf, l); diff --git a/main/utils.c b/main/utils.c index eff270fba..9a7a3acd4 100644 --- a/main/utils.c +++ b/main/utils.c @@ -1066,8 +1066,11 @@ int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*st a->start_routine = start_routine; a->data = data; start_routine = dummy_start; - asprintf(&a->name, "%-20s started at [%5d] %s %s()", - start_fn, line, file, caller); + if (asprintf(&a->name, "%-20s started at [%5d] %s %s()", + start_fn, line, file, caller) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + a->name = NULL; + } data = a; } #endif /* !LOW_MEMORY */ |