From patchwork Tue Aug 25 14:09:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21921 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 77CCC44B5EC for ; Tue, 25 Aug 2020 17:17:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5C03968AC1E; Tue, 25 Aug 2020 17:17:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 304FD68ABC3 for ; Tue, 25 Aug 2020 17:17:25 +0300 (EEST) Received: by mail-ed1-f65.google.com with SMTP id l63so8347865edl.9 for ; Tue, 25 Aug 2020 07:17:25 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=PX6zlZXigW99uy6lk33afbTh54z0d6K2G3o6Zovwk/g=; b=JtMcN8ajYzpbWI+A+3kjZQut1KdABGuJKX8L9bFN9A1jgFyU5apiYMjezAqokxJkSK XnbgZND8FOb47qlyBZN54l3/bD5cUbbWbEnPPr9QR6cKJJbgj41L2nepPNvwNg6BiGgg svwpTADw/6WuYjZwNHJYuKzv5juqw/FoCC6YhWjmA5tSghYlFjuiYiTpX/QL50gG3bBt /1klSmpEBGMSNpzBUh1gnzBUYQJCVdgZIa5K42vv1YZ/bLvkTRpKdfoRFQdVsA4xCXSt +udCP4vxfZZT/kjXcJRHQZ+ZVpFrcNU2D5NbrIqTX/auHYbZThl2HfVBPZ8Sp5pSkIIu ufsQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=PX6zlZXigW99uy6lk33afbTh54z0d6K2G3o6Zovwk/g=; b=d6gMEro5dBs0wHaEcIkG4MWDpnfmXctfyBoeQ7MzM6+ZU2TWlDXjCt4G5MxmUFyJi8 Odn8hE6JiAbBuH5L8A2KlHO4efp028aOF+EXu8acstXQAptUbYJLqMWZZO3kqPRU2p9W gFh+QbUV46zFnXMRdFLcNXlUzF0gJEIlXgxi+uiSCX7byZS8vq9QXtEuimqhg3Zf6Pkq 0EAybXm8B+S7MDMqAmdyuWrB467mSxTR8yMMu4fTnlPHGZWc88rIRAjZjP6w20FBoESW 5Z3aH7NpyvOJlOX91grWOTynYfutSyECUemyCtd450GW8uylkpVHKstTqx4AO9CwmoJp PjkQ== X-Gm-Message-State: AOAM533vCNRprtfbrMfqQIOgV6E6Vpxgz+rVoIFq9CV1MuKhY9FNo1/m /Yf2TM173usOUieYjEn9xY+xA+DHFjg= X-Google-Smtp-Source: ABdhPJxUJdYpT8bQXUhD6AWKuVhSoKcBZ5Ezi4q4wwK26jvjFOWO30T6OtxMbplvrgAatGxCO/WlYg== X-Received: by 2002:a50:ee0a:: with SMTP id g10mr10026503eds.289.1598364623299; Tue, 25 Aug 2020 07:10:23 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id k25sm10169806edx.96.2020.08.25.07.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:22 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:25 +0200 Message-Id: <20200825140927.16433-17-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200825140927.16433-1-andreas.rheinhardt@gmail.com> References: <20200825140927.16433-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/19] avfilter/vf_signature: Avoid cast from function pointer to void* 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" The signature filter uses qsort, but its compare function doesn't have the signature required of such a function; therefore it casts the function pointer to void. Yet this is wrong: C90 only guarantees that one can convert a pointer to any incomplete type or object type to void* and back with the result comparing equal to the original which makes pointers to void generic pointers to incomplete or object type. Yet C90 lacks a generic function pointer type. C99 additionally guarantees that a pointer to a function of one type may be converted to a pointer to a function of another type with the result and the original comparing equal when converting back. This makes any function pointer type a generic function pointer type. Yet even this does not make pointers to void generic function pointers. Both GCC and Clang emit warnings for this when in pedantic mode. This commit fixes this by modifying the compare function to comply with the expected signature. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_signature.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c index 80957d0047..32a6405e14 100644 --- a/libavfilter/vf_signature.c +++ b/libavfilter/vf_signature.c @@ -132,8 +132,9 @@ static uint64_t get_block_sum(StreamContext *sc, uint64_t intpic[32][32], const return sum; } -static int cmp(const uint64_t *a, const uint64_t *b) +static int cmp(const void *x, const void *y) { + const uint64_t *a = x, *b = y; return *a < *b ? -1 : ( *a > *b ? 1 : 0 ); } @@ -291,7 +292,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) } /* get threshold */ - qsort(sortsignature, elemcat->elem_count, sizeof(uint64_t), (void*) cmp); + qsort(sortsignature, elemcat->elem_count, sizeof(uint64_t), cmp); th = sortsignature[(int) (elemcat->elem_count*0.333)]; /* ternarize */ @@ -317,7 +318,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) } /* confidence */ - qsort(conflist, DIFFELEM_SIZE, sizeof(uint64_t), (void*) cmp); + qsort(conflist, DIFFELEM_SIZE, sizeof(uint64_t), cmp); fs->confidence = FFMIN(conflist[DIFFELEM_SIZE/2], 255); /* coarsesignature */