From patchwork Tue Aug 30 22:49:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Burgess IV X-Patchwork-Id: 343 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp82619vsd; Tue, 30 Aug 2016 15:50:04 -0700 (PDT) X-Received: by 10.28.211.10 with SMTP id k10mr6381378wmg.16.1472597403993; Tue, 30 Aug 2016 15:50:03 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n24si499684wmi.20.2016.08.30.15.50.00; Tue, 30 Aug 2016 15:50:03 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@chromium.org; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=chromium.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D35E9689D5E; Wed, 31 Aug 2016 01:49:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f171.google.com (mail-pf0-f171.google.com [209.85.192.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2201168972F for ; Wed, 31 Aug 2016 01:49:45 +0300 (EEST) Received: by mail-pf0-f171.google.com with SMTP id p64so12255403pfb.1 for ; Tue, 30 Aug 2016 15:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=tbpIIGpuThAQXJjq3AC/aCtcPJQ210Wyapa9mUz3vK0=; b=Whkfl58tOVrlFnOkBWbyZWXxX33BwSvkMp9/N2hSlO4IHO77OCNKshqMfKLbzQQRCt HXBlY3uekrf/g3cQ0N/r7PbNvpvPj5d1W7Ht0XVI4XV+ZKry9Pf4FlcmAYJv3qmwjkla bXdAdfa9qE1eDbGGJvW1rwQsRZcjKifNbMPwU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tbpIIGpuThAQXJjq3AC/aCtcPJQ210Wyapa9mUz3vK0=; b=et9e3rrulNo880BmLrTVKz97fOhdBSDGn/Fy1rSzNdJLq+1jkaHbG2LmiYRaLLYYXo fXx1KUBG9NQqrekG7hBNeIaJtmVMB8fmq5yR4lMG5FhJFum5r/FXWVQBUIko9Kz2QWAM wSJLQYZI6dekGlQwhJoQQ1ZbvobLjT0UwN84OipwI2+f5qPKLACOYRtLchG1xp5Io96e mW06tVEuSlRWfAFX4U1u/WX4KcJZFKsbryAM1OUE+qu+ORsV+PzbtJ+zFuztmoTeBuxu IyaADoj3byY3u6erJK84TDaypJSLz0+Gd4wn3zmst91io46Anu7xgPaX0ctR82YygKtj 5/Bg== X-Gm-Message-State: AE9vXwN24sXFRV+cxjwfME+QSFsAm208C81+7clbt//KB65AqQR5ylb6Otl/8iaSSOhFYD25 X-Received: by 10.98.219.66 with SMTP id f63mr3354203pfg.41.1472597389902; Tue, 30 Aug 2016 15:49:49 -0700 (PDT) Received: from gbiv-desktop.mtv.corp.google.com ([172.17.222.222]) by smtp.gmail.com with ESMTPSA id n80sm59604419pfi.19.2016.08.30.15.49.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Aug 2016 15:49:49 -0700 (PDT) From: George Burgess IV To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Aug 2016 15:49:04 -0700 Message-Id: <1472597344-8124-1-git-send-email-gbiv@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Subject: [FFmpeg-devel] [PATCH v2] Let clang-FORTIFY build; NFC. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: George Burgess IV MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" ChromeOS is adopting a new FORTIFY implementation tailored for clang. As an artifact of how this new FORTIFY is implemented, a handful of implicit conversion warnings get turned into errors. This patch fixes the implicit conversions in ffmpeg that clang-FORTIFY has an issue with. Signed-off-by: George Burgess IV --- If anyone feels that more comments would be useful, I'll add them above some of the char* casts, so it's a bit more obvious why we have said casts. Testing methodology was "run `make fate` and see what doesn't build." If there are other targets that would be good to try, I'm happy to check with those, as well. :) libavcodec/pamenc.c | 2 +- libavcodec/pnmenc.c | 4 ++-- libavcodec/xbmenc.c | 8 +++++--- libavcodec/xsubenc.c | 2 +- libavfilter/af_astats.c | 4 ++-- libavfilter/avf_aphasemeter.c | 2 +- libavformat/flacenc.c | 2 +- libavformat/http.c | 4 ++-- libavformat/matroskaenc.c | 3 ++- libavformat/md5proto.c | 3 ++- libavformat/nutenc.c | 4 ++-- libavformat/rtmppkt.c | 4 ++-- libavutil/hash.c | 2 +- libavutil/opt.c | 5 +++-- 14 files changed, 27 insertions(+), 22 deletions(-) diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c index 50c9fcb..143d38f 100644 --- a/libavcodec/pamenc.c +++ b/libavcodec/pamenc.c @@ -98,7 +98,7 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt, bytestream = pkt->data; bytestream_end = pkt->data + pkt->size; - snprintf(bytestream, bytestream_end - bytestream, + snprintf((char *)bytestream, bytestream_end - bytestream, "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLTYPE %s\nENDHDR\n", w, h, depth, maxval, tuple_type); bytestream += strlen(bytestream); diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c index ba9478d..f1bcbc6 100644 --- a/libavcodec/pnmenc.c +++ b/libavcodec/pnmenc.c @@ -80,12 +80,12 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, default: return -1; } - snprintf(bytestream, bytestream_end - bytestream, + snprintf((char *)bytestream, bytestream_end - bytestream, "P%c\n%d %d\n", c, avctx->width, h1); bytestream += strlen(bytestream); if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE) { int maxdepth = (1 << av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth) - 1; - snprintf(bytestream, bytestream_end - bytestream, + snprintf((char *)bytestream, bytestream_end - bytestream, "%d\n", maxdepth); bytestream += strlen(bytestream); } diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c index b25615f..7f7fbc0 100644 --- a/libavcodec/xbmenc.c +++ b/libavcodec/xbmenc.c @@ -28,14 +28,16 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *p, int *got_packet) { int i, j, ret, size, linesize; - uint8_t *ptr, *buf; + // buf is a char* instead of a uint8_t* to make FORTIFY on clang happy. + char *buf; + uint8_t *ptr; linesize = (avctx->width + 7) / 8; size = avctx->height * (linesize * 7 + 2) + 110; if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0) return ret; - buf = pkt->data; + buf = (char *)pkt->data; ptr = p->data[0]; buf += snprintf(buf, 32, "#define image_width %u\n", avctx->width); @@ -49,7 +51,7 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } buf += snprintf(buf, 5, " };\n"); - pkt->size = buf - pkt->data; + pkt->size = (uint8_t *)buf - pkt->data; pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; return 0; diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c index b3da909..a4a8221 100644 --- a/libavcodec/xsubenc.c +++ b/libavcodec/xsubenc.c @@ -163,7 +163,7 @@ FF_ENABLE_DEPRECATION_WARNINGS return -1; } - snprintf(buf, 28, + snprintf((char *)buf, 28, "[%02d:%02d:%02d.%03d-%02d:%02d:%02d.%03d]", start_tc[3], start_tc[2], start_tc[1], start_tc[0], end_tc[3], end_tc[2], end_tc[1], end_tc[0]); diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c index e7f9675..32c6041 100644 --- a/libavfilter/af_astats.c +++ b/libavfilter/af_astats.c @@ -211,8 +211,8 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d, static void set_meta(AVDictionary **metadata, int chan, const char *key, const char *fmt, double val) { - uint8_t value[128]; - uint8_t key2[128]; + char value[128]; + char key2[128]; snprintf(value, sizeof(value), fmt, val); if (chan) diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c index 8e8b292..4afc6bb 100644 --- a/libavfilter/avf_aphasemeter.c +++ b/libavfilter/avf_aphasemeter.c @@ -190,7 +190,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) metadata = avpriv_frame_get_metadatap(out); if (metadata) { - uint8_t value[128]; + char value[128]; snprintf(value, sizeof(value), "%f", fphase); av_dict_set(metadata, "lavfi.aphasemeter.phase", value, 0); diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index 89b21e9..8ef4292 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -115,7 +115,7 @@ static int flac_write_header(struct AVFormatContext *s) av_log(s, AV_LOG_WARNING, "A WAVEFORMATEXTENSIBLE_CHANNEL_MASK is " "already present, this muxer will not overwrite it.\n"); } else { - uint8_t buf[32]; + char buf[32]; snprintf(buf, sizeof(buf), "0x%"PRIx64, par->channel_layout); av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0); } diff --git a/libavformat/http.c b/libavformat/http.c index adb3d92..282310b 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1095,7 +1095,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, if (s->headers) av_strlcpy(headers + len, s->headers, sizeof(headers) - len); - snprintf(s->buffer, sizeof(s->buffer), + snprintf((char *)s->buffer, sizeof(s->buffer), "%s %s HTTP/1.1\r\n" "%s" "%s" @@ -1593,7 +1593,7 @@ redo: authstr = ff_http_auth_create_response(&s->proxy_auth_state, auth, path, "CONNECT"); - snprintf(s->buffer, sizeof(s->buffer), + snprintf((char *)s->buffer, sizeof(s->buffer), "CONNECT %s HTTP/1.1\r\n" "Host: %s\r\n" "Connection: close\r\n" diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 2a2877f..2788ff7 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -576,7 +576,8 @@ static int put_flac_codecpriv(AVFormatContext *s, const char *vendor = (s->flags & AVFMT_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT; AVDictionary *dict = NULL; - uint8_t buf[32], *data, *p; + char buf[32]; + uint8_t *data, *p; int64_t len; snprintf(buf, sizeof(buf), "0x%"PRIx64, par->channel_layout); diff --git a/libavformat/md5proto.c b/libavformat/md5proto.c index 0e04b90..23a067a 100644 --- a/libavformat/md5proto.c +++ b/libavformat/md5proto.c @@ -57,7 +57,8 @@ static int md5_close(URLContext *h) { struct MD5Context *c = h->priv_data; const char *filename = h->filename; - uint8_t md5[16], buf[64]; + uint8_t md5[16]; + char buf[64]; URLContext *out; int i, err = 0; diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 9e422e1..d698711 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -533,7 +533,7 @@ static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id) { count += add_info(dyn_bc, "Disposition", ff_nut_dispositions[i].str); } if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { - uint8_t buf[256]; + char buf[256]; if (st->r_frame_rate.num>0 && st->r_frame_rate.den>0) snprintf(buf, sizeof(buf), "%d/%d", st->r_frame_rate.num, st->r_frame_rate.den); else @@ -842,7 +842,7 @@ static int write_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int unsigned flags; AVIOContext *dyn_bc; int sm_data_count = 0; - uint8_t tmp[256]; + char tmp[256]; uint8_t *dyn_buf; ret = avio_open_dyn_buf(&dyn_bc); diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index 0d693c2..4856808 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -494,10 +494,10 @@ int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, if (size == namelen && !memcmp(data-size, name, namelen)) { switch (*data++) { case AMF_DATA_TYPE_NUMBER: - snprintf(dst, dst_size, "%g", av_int2double(AV_RB64(data))); + snprintf((char *)dst, dst_size, "%g", av_int2double(AV_RB64(data))); break; case AMF_DATA_TYPE_BOOL: - snprintf(dst, dst_size, "%s", *data ? "true" : "false"); + snprintf((char *)dst, dst_size, "%s", *data ? "true" : "false"); break; case AMF_DATA_TYPE_STRING: len = bytestream_get_be16(&data); diff --git a/libavutil/hash.c b/libavutil/hash.c index 7037b0d..27637b7 100644 --- a/libavutil/hash.c +++ b/libavutil/hash.c @@ -215,7 +215,7 @@ void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size) av_hash_final(ctx, buf); for (i = 0; i < FFMIN(rsize, size / 2); i++) - snprintf(dst + i * 2, size - i * 2, "%02x", buf[i]); + snprintf((char *)dst + i * 2, size - i * 2, "%02x", buf[i]); } void av_hash_final_b64(struct AVHashContext *ctx, uint8_t *dst, int size) diff --git a/libavutil/opt.c b/libavutil/opt.c index cd16bd1..f7f5225 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -733,7 +733,8 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) { void *dst, *target_obj; const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); - uint8_t *bin, buf[128]; + uint8_t *bin; + char buf[128]; int len, i, ret; int64_t i64; @@ -795,7 +796,7 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) } bin = *(uint8_t **)dst; for (i = 0; i < len; i++) - snprintf(*out_val + i * 2, 3, "%02X", bin[i]); + snprintf(*(char **)out_val + i * 2, 3, "%02X", bin[i]); return 0; case AV_OPT_TYPE_IMAGE_SIZE: ret = snprintf(buf, sizeof(buf), "%dx%d", ((int *)dst)[0], ((int *)dst)[1]);