From patchwork Wed Jul 17 03:29:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13973 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 051CC448F04 for ; Wed, 17 Jul 2019 06:35:26 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D57D168AE27; Wed, 17 Jul 2019 06:35:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 514C268AE07 for ; Wed, 17 Jul 2019 06:35:19 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id n9so23078283wrr.4 for ; Tue, 16 Jul 2019 20:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qDi0rRt50+8MeY59FkUUci+YsFjiESSdZxY3SNc/gl4=; b=hIMVI04Kle73s8lu/r/nPWmEa6Wpo92n1s2NjqsqUNP7i9pkxi6uo/+8JY6tB3j8IL tyqQXTIKwEh4R2D5woejMPp7osYvF2cSWLIooU2wevR8iXCSIXlP9Yp7V+VKpHU6MeLk 2oTgdDn75n2IBTI3IPXonjBL8MxoE+PIvilCtsTtnQZI/dAinmw/To9GElEwMl+uTw5l xK8EMvl7J4rXuojTtjLxEjIg48YDtztVn/YQtLuJo0Eyv1GHAEth2hX1xigpVRzUto5S fA/BEWrFcSxJgWROA8Rg0bjZvQu1av93yHBkGVVeowCfC1rLbVP8Pv4xGenBq/t31pxA Q6+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qDi0rRt50+8MeY59FkUUci+YsFjiESSdZxY3SNc/gl4=; b=iq0X/MjeJFrWerUPkJMD5QfDLDIOfC6mkuuz8CB0/8+Hbbg7m8piBUvMtEuwllYzMe nLYtz0vERozaIT9JSlbpbAMyqo0LrZXkJ6xoBVeOMBmUEI7s3wvUaue13SvAom3NJWOm J5Xj1DTcXOWhoeA1HJlPENqmeBEO900tG0f7qq5RTfq6ONGihIa7XkoNf3/iBJR2w7Hh RvELRRGopszSTE2A1ZttW9SJ72MDP50c9tezUDf576k3gG1ygaWy6iPSJvC9PWiqixze h6md/5KJvnXMJfZ8GtT8Hu+BEwnGwgfqWudjHYfis0hzBxEU2KyWS/ajQiRizG5r2TPa xEuA== X-Gm-Message-State: APjAAAXlAosNKIqS0UiwduMgt6PsvixMNMYnTdD6t0o1YHIYXdJVfgtx L+0vCDwu8gpk70NPveEoPVzJT69g X-Google-Smtp-Source: APXvYqweXYSUX0MnagLy5hlEnBqwhVAd4ryOJyv85cJToq/EDdPfs3LCDHzKp+inSTSxUvu5oK0TeQ== X-Received: by 2002:adf:eb51:: with SMTP id u17mr38174998wrn.257.1563334204781; Tue, 16 Jul 2019 20:30:04 -0700 (PDT) Received: from localhost.localdomain (ipbcc08b8f.dynamic.kabel-deutschland.de. [188.192.139.143]) by smtp.gmail.com with ESMTPSA id s188sm16976028wmf.40.2019.07.16.20.30.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 20:30:04 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 Jul 2019 05:29:40 +0200 Message-Id: <20190717032940.48332-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] matroskadec: Add sizes to forward declarations 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Unknown-length elements end when an element not allowed in them, but allowed at a higher level is encountered. In order to check for this, c1abd95a added a pointer to every syntax level's parent to each EbmlSyntax. Given that the parent must of course also reference the child in order to be able to enter said child level, one needs to use forward declarations. These forward declarations constitute tentative definitions and tentative definitions with internal linkage (like our syntaxes) must not be an incomplete type. Yet they were an incomplete type and while GCC and Clang did not even warn about this (on default warning levels), it broke compilation with MSVC. Therefore this commit adds the sizes. Signed-off-by: Andreas Rheinhardt --- 1. I am terribly sorry for this. I did test with both GCC and Clang, but not with -pedantic, but only with default warning levels. 2. I don't have an MSVC setup here, so could please someone confirm that this patch indeed fixes the compilation? All I know is that GCC's -pedantic warnings are gone with this patch and that the requirement that tentative definitions with internal linkage must not be of incomplete type is fulfilled now. libavformat/matroskadec.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index b97189e674..fb0356e7b7 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -389,12 +389,16 @@ typedef struct MatroskaDemuxContext { #define CHILD_OF(parent) { .def = { .n = parent } } -static const EbmlSyntax ebml_syntax[], matroska_segment[], matroska_track_video_color[], matroska_track_video[], - matroska_track[], matroska_track_encoding[], matroska_track_encodings[], - matroska_track_combine_planes[], matroska_track_operation[], matroska_tracks[], - matroska_attachments[], matroska_chapter_entry[], matroska_chapter[], matroska_chapters[], - matroska_index_entry[], matroska_index[], matroska_tag[], matroska_tags[], matroska_seekhead[], - matroska_blockadditions[], matroska_blockgroup[], matroska_cluster_parsing[]; +// The following forward declarations need their size because +// a tentative definition with internal linkage must not be an +// incomplete type (6.7.2 in C90, 6.9.2 in C99). +// Removing the sizes breaks MSVC. +static const EbmlSyntax ebml_syntax[3], matroska_segment[9], matroska_track_video_color[15], matroska_track_video[19], + matroska_track[27], matroska_track_encoding[6], matroska_track_encodings[2], + matroska_track_combine_planes[2], matroska_track_operation[2], matroska_tracks[2], + matroska_attachments[2], matroska_chapter_entry[9], matroska_chapter[6], matroska_chapters[2], + matroska_index_entry[3], matroska_index[2], matroska_tag[3], matroska_tags[2], matroska_seekhead[2], + matroska_blockadditions[2], matroska_blockgroup[8], matroska_cluster_parsing[8]; static const EbmlSyntax ebml_header[] = { { EBML_ID_EBMLREADVERSION, EBML_UINT, 0, offsetof(Ebml, version), { .u = EBML_VERSION } },