From patchwork Wed Apr 18 19:52:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 8498 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.85 with SMTP id c82csp3473087jad; Wed, 18 Apr 2018 12:52:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/GKfoDqJSQGcRovW3rlcZrr1zN++lV3UESSBqszvormmAot4jDHR1MMO67sdONImwKeT+d X-Received: by 2002:adf:90e3:: with SMTP id i90-v6mr2742438wri.100.1524081177213; Wed, 18 Apr 2018 12:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524081177; cv=none; d=google.com; s=arc-20160816; b=OKSylQfNd32YhEDb4gEim11bqD+WG23glyvL4FkaPxiJiCGvSq4xv4M1qJNArFHPL/ wVtH3RE58lZsc0rKLUAVCQSXiROM959mLaHBxG6uC7yI8SJiR3cFKEIb2yFWBgG2tkhV lEVSO7hNfS8OGGoetW3EMACiOyf8pExdesETSQMhacxcr5SDY0aIa/AFjMTR3weTYsv+ 0Imq228utSphLMCsuTKQQC2pQVIYrNLCmQdsHr+x3TqDE0GyTUmxvycY3PC/uAZ5NctU wqnZkRduCMlmnRdP96tRCaFV+dNYjUAIxUSGfn4nFrwkz4gro8ID0gVzZdthzxz4bD9M cC0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=MhBcOEbsiKZH2MI03x7P1J1fLdAJb8/l4uQ+en2g78M=; b=ejheOElWqPUol920EicUCZBQmf63sT8HTI6BFc1mfPsv+JZwXTUCIVp8Xl0LijLuWU qCoxKfp4RkTEy4OIY8JQC5JTP4eHzLfxbxgEk9nVZVOyqFaNAHcCjd2JjofdXoxjuu00 sxlzyA9cLHBbY8YIOvf1X79d6MJb9BW0vSIFaj0IYx9QXk6Exz7BudFf4GjRdr2+aLNK PNHxfJhlP9De18/f9+/+VIj2t20b1opmuxSPbGUMYWzVoAfGQrkNk+UxheL+ZZ3xEiUG sYC7tqiV6Ic42oZD31+UgpIU+ybwodLz3A8hd1RWEuMXKY9iEHdUcHSgiQnjdGZpi9lD 5jDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=uvrdCpQE; 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 sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h13-v6si1542361wrc.19.2018.04.18.12.52.56; Wed, 18 Apr 2018 12:52:57 -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=@gmail.com header.s=20161025 header.b=uvrdCpQE; 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 sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C29B468A18C; Wed, 18 Apr 2018 22:52:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f42.google.com (mail-it0-f42.google.com [209.85.214.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EFAA368A039 for ; Wed, 18 Apr 2018 22:52:20 +0300 (EEST) Received: by mail-it0-f42.google.com with SMTP id n81-v6so3922866ita.1 for ; Wed, 18 Apr 2018 12:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=cwvkb/Gjh5r13iDEfgdtdRa+DEIsu22ykSak1sX7U5g=; b=uvrdCpQE37wBh/Ga43QLEvG6U+YMXjgcSZWYFThHeXbM734TtVpXABpl+MoCSF3XzP hiijuk1l4UPrmi0yx90ImsQYZOw3Ge1+zfgw8JTf9SI+7C1sMbLb5U992TVdmaxU3ZZL ZZoj8LOBB1AHxv6jydsgmVDXYF64rXfXC+I8R+udQRBQpGUxcjl4C6mMXFCvIu03qtEh YmlABScLgo5+IM2jpchEjTyOlaEUa2zn9UwQ13fhx4GfUguX0I0cDvdOeMbfAzRuKM6b fgGBZq4bSgvU+O154DJwsIbTco1o0Ij/arBG1sJ11qwgX8yc5WLOOi969AnJ48F4btnM ayFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=cwvkb/Gjh5r13iDEfgdtdRa+DEIsu22ykSak1sX7U5g=; b=ntC9RJQX0xQS64pF4OE3FoacQRqofysyWuRijn8IQYCJOwRX2Q4LXFetnF2u7ahf4E kEX31tUSEIUhblMIBvEXQ2WcLlVe0AZrYds8YM4FY15LYSN05fKANrpXODAaZpn+sRch 8PXpKIDl41qVtRP7zyWTdGT7wYtrXXgmIXKF5de++kuPKhKwb2XNvKxMlG3Rq35AitRq aUNAzCUeQ2GyDx4oQ0RcEc0QRxF/iVnPbo8PhUnVBLND44Htqpyj5pKn6HwZDBSyQFyp a0hlRQgJRvJCJwfMYDcrz9L888ykNuoCReIB80Xqd7EdcmXTQZmzLidfrpJD9G3aQpd6 1aLA== X-Gm-Message-State: ALQs6tBkDy8sbqVh8ukpu0Z+pExbVZ9R1rDe6WH+/7WZ/XWYsJ8Bpbn+ bqCdtubilFln/izPNfvV2N7I3tMY3bmd8dKBMaE= X-Received: by 2002:a24:1d94:: with SMTP id 142-v6mr3891149itj.39.1524081166675; Wed, 18 Apr 2018 12:52:46 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:9041:0:0:0:0:0 with HTTP; Wed, 18 Apr 2018 12:52:45 -0700 (PDT) In-Reply-To: References: From: Carl Eugen Hoyos Date: Wed, 18 Apr 2018 21:52:45 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH]lavf/dashdec: Do not use memcpy() to copy a struct 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 2018-04-18 21:10 GMT+02:00, James Almer : > On 4/18/2018 2:45 PM, Carl Eugen Hoyos wrote: >> Hi! >> >> Attached patch is supposed to fix a warning (and a bug), is this the >> right and preferred fix? >> >> Please comment, Carl Eugen >> >> >> 0001-lavf-dashdec-Do-not-use-memcpy-to-copy-a-struct.patch >> >> >> From cf7d2aefc1a3b3a2e9f578ede43906ed6ee96bfd Mon Sep 17 00:00:00 2001 >> From: Carl Eugen Hoyos >> Date: Wed, 18 Apr 2018 19:42:57 +0200 >> Subject: [PATCH] lavf/dashdec: Do not use memcpy() to copy a struct. >> >> Fixes a warning: >> libavformat/dashdec.c:1900:65: warning: argument to 'sizeof' in 'memcpy' >> call is the same pointer type 'struct fragment *' as the destination; >> expected 'struct fragment' or an explicit length >> --- >> libavformat/dashdec.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c >> index 6304ad9..917fb54 100644 >> --- a/libavformat/dashdec.c >> +++ b/libavformat/dashdec.c >> @@ -1897,7 +1897,7 @@ static int init_section_compare_audio(DASHContext >> *c) >> >> static void copy_init_section(struct representation *rep_dest, struct >> representation *rep_src) >> { >> - memcpy(rep_dest->init_section, rep_src->init_section, >> sizeof(rep_src->init_section)); >> + rep_dest->init_section = rep_src->init_section; > > This would only copy the pointer. The fact memcpy was used here makes me > think the intention was to copy the contents of the struct, so something > like > > *rep_dest->init_section = *rep_src->init_section; Of course. New patch attached, Carl Eugen From cf7d2aefc1a3b3a2e9f578ede43906ed6ee96bfd Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 18 Apr 2018 19:42:57 +0200 Subject: [PATCH] lavf/dashdec: Do not use memcpy() to copy a struct. Fixes a warning: libavformat/dashdec.c:1900:65: warning: argument to 'sizeof' in 'memcpy' call is the same pointer type 'struct fragment *' as the destination; expected 'struct fragment' or an explicit length --- libavformat/dashdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 6304ad9..917fb54 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1897,7 +1897,7 @@ static int init_section_compare_audio(DASHContext *c) static void copy_init_section(struct representation *rep_dest, struct representation *rep_src) { - memcpy(rep_dest->init_section, rep_src->init_section, sizeof(rep_src->init_section)); + *rep_dest->init_section = *rep_src->init_section; rep_dest->init_sec_buf = av_mallocz(rep_src->init_sec_buf_size); memcpy(rep_dest->init_sec_buf, rep_src->init_sec_buf, rep_src->init_sec_data_len); rep_dest->init_sec_buf_size = rep_src->init_sec_buf_size; -- 1.7.10.4