com php-src: Return bool from zlog_stream_set_msg_{pr efix,suffix}: sapi/fpm/fpm/zlog.c sapi/fpm/fpm/zlog .h

From: Date: Sun, 22 Jul 2018 16:40:38 +0000
Subject: com php-src: Return bool from zlog_stream_set_msg_{pr efix,suffix}: sapi/fpm/fpm/zlog.c sapi/fpm/fpm/zlog .h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-102640@lists.php.net to get a copy of this message
Commit: 26cd84d19f164f592f24593f4d1d1f7bd10696a6 Author: Jakub Zelenka <bukka@php.net> Sun, 22 Jul 2018 17:40:38 +0100 Parents: 89e2202cb5e8a2308055d22122375f72c479e108 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=26cd84d19f164f592f24593f4d1d1f7bd10696a6 Log: Return bool from zlog_stream_set_msg_{prefix,suffix} Changed paths: M sapi/fpm/fpm/zlog.c M sapi/fpm/fpm/zlog.h Diff: diff --git a/sapi/fpm/fpm/zlog.c b/sapi/fpm/fpm/zlog.c index cd5260b..0fb6b95 100644 --- a/sapi/fpm/fpm/zlog.c +++ b/sapi/fpm/fpm/zlog.c @@ -595,14 +595,14 @@ void zlog_stream_set_msg_quoting(struct zlog_stream *stream, zlog_bool quote) /* } /* }}} */ -ssize_t zlog_stream_set_msg_prefix(struct zlog_stream *stream, const char *fmt, ...) /* {{{ */ +zlog_bool zlog_stream_set_msg_prefix(struct zlog_stream *stream, const char *fmt, ...) /* {{{ */ { char buf[MAX_WRAPPING_PREFIX_LENGTH]; size_t len; va_list args; if (!stream->decorate) { - return -1; + return ZLOG_TRUE; } va_start(args, fmt); @@ -611,7 +611,7 @@ ssize_t zlog_stream_set_msg_prefix(struct zlog_stream *stream, const char *fmt, stream->msg_prefix = malloc(len + 1); if (stream->msg_prefix == NULL) { - return -1; + return ZLOG_FALSE; } memcpy(stream->msg_prefix, buf, len); stream->msg_prefix[len] = 0; @@ -621,12 +621,12 @@ ssize_t zlog_stream_set_msg_prefix(struct zlog_stream *stream, const char *fmt, } /* }}} */ -ssize_t zlog_stream_set_msg_suffix( +zlog_bool zlog_stream_set_msg_suffix( struct zlog_stream *stream, const char *suffix, const char *final_suffix) /* {{{ */ { size_t len; if (!stream->wrap || !stream->decorate) { - return -1; + return ZLOG_TRUE; } if (suffix != NULL && final_suffix != NULL) { @@ -635,33 +635,35 @@ ssize_t zlog_stream_set_msg_suffix( len = stream->msg_suffix_len + stream->msg_final_suffix_len + 2; stream->msg_suffix = malloc(len); if (stream->msg_suffix == NULL) { - return -1; + return ZLOG_FALSE; } stream->msg_final_suffix = stream->msg_suffix + stream->msg_suffix_len + 1; memcpy(stream->msg_suffix, suffix, stream->msg_suffix_len + 1); memcpy(stream->msg_final_suffix, final_suffix, stream->msg_final_suffix_len + 1); - return len; + return ZLOG_TRUE; } if (suffix != NULL) { - stream->msg_suffix_len = len = strlen(suffix); - stream->msg_suffix = malloc(len + 1); + stream->msg_suffix_len = strlen(suffix); + len = stream->msg_suffix_len + 1; + stream->msg_suffix = malloc(len); if (stream->msg_suffix == NULL) { - return -1; + return ZLOG_FALSE; } - memcpy(stream->msg_suffix, suffix, stream->msg_suffix_len + 1); - return len; + memcpy(stream->msg_suffix, suffix, len); + return ZLOG_TRUE; } if (final_suffix != NULL) { - stream->msg_final_suffix_len = len = strlen(final_suffix); - stream->msg_final_suffix = malloc(len + 1); + stream->msg_final_suffix_len = strlen(final_suffix); + len = stream->msg_final_suffix_len + 1; + stream->msg_final_suffix = malloc(len); if (stream->msg_final_suffix == NULL) { - return -1; + return ZLOG_FALSE; } - memcpy(stream->msg_final_suffix, final_suffix, stream->msg_final_suffix_len + 1); - return len; + memcpy(stream->msg_final_suffix, final_suffix, len); + return ZLOG_TRUE; } - return 0; + return ZLOG_TRUE; } /* }}} */ diff --git a/sapi/fpm/fpm/zlog.h b/sapi/fpm/fpm/zlog.h index ce97702..3869523 100644 --- a/sapi/fpm/fpm/zlog.h +++ b/sapi/fpm/fpm/zlog.h @@ -96,9 +96,9 @@ void zlog_stream_init_ex(struct zlog_stream *stream, int flags, int fd); void zlog_stream_set_decorating(struct zlog_stream *stream, zlog_bool decorate); void zlog_stream_set_wrapping(struct zlog_stream *stream, zlog_bool wrap); void zlog_stream_set_msg_quoting(struct zlog_stream *stream, zlog_bool quote); -ssize_t zlog_stream_set_msg_prefix(struct zlog_stream *stream, const char *fmt, ...) +zlog_bool zlog_stream_set_msg_prefix(struct zlog_stream *stream, const char *fmt, ...) __attribute__ ((format(printf,2,3))); -ssize_t zlog_stream_set_msg_suffix( +zlog_bool zlog_stream_set_msg_suffix( struct zlog_stream *stream, const char *suffix, const char *final_suffix); #define zlog_stream_prefix(stream) \ zlog_stream_prefix_ex(stream, __func__, __LINE__)

« previous php.cvs (#102640) next »