From patchwork Mon Feb 15 06:53:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuo Mi X-Patchwork-Id: 25631 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 7A0AB44AB58 for ; Mon, 15 Feb 2021 08:54:12 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 479B068091F; Mon, 15 Feb 2021 08:54:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B5EB6805D7 for ; Mon, 15 Feb 2021 08:54:05 +0200 (EET) Received: by mail-pl1-f173.google.com with SMTP id z7so3184677plk.7 for ; Sun, 14 Feb 2021 22:54:05 -0800 (PST) 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=ylMTvEdHI8cdmIFimgEvdrgxvUlRvdNXjRiUgNTAAV8=; b=uEVoPwA7BrAiDWSeFOtFvlfubaox9QFKGU7oTJmH506HIT52cGeZYiZoDgQGFnL4Va 1cv6pXDEBk6YE05pkMgPjPiZIJAW58FUqc7wgGS/md42wluR126J8qqTLTcwGQ+8FyDk bO081f+FPvaNythLpUHpIeEOkD/wJyS8E55zgiK8na40pXkuOEuEE+KcSZHDJt60PV6F mbdRmodPqDktIOlb1VOuNmKmaIY2iMF5oWoI7j+Z+ntrEfULLH0HbOp1AQJRY2h24JH9 OGTsEUK0S/8fDQA5hxIerzZ+49jjz5pJLw3Yx1A1bVw/1c5n+oKUfvFsm3sZY4cmrrNt 5Zrg== 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=ylMTvEdHI8cdmIFimgEvdrgxvUlRvdNXjRiUgNTAAV8=; b=KMUb3lPbTzVbnPiBUhEyZ8PloznYssakOPOnTF2THwI3gQxF2msNmBq/bHF1nlSDES c0WjMjyf/afQkD/UDTr+ifQYXn8bCq8slYfREBQvnNEjpu+4/ijrECAx2Uf7PFB6YVWu v0NrkXg8zAZkQsrsrpQPU2Vf4qNZQtfw2wV9P9UP+z1sBh3z3uM7OCQNbOLvWwQ3L9rj FYnFJXj3sxkQfi25lgXIa+r8Vtf5Vq6hwwRPRukyMgrBMK3n2EUiGR3XpQqn3RoTZdcP Rb2pT9lGnicubXUvLjW1ayy+vPkGipNhzmZJFMJcW9jT25QMBAipNVQ4Xq7ShFff5xfw kCAQ== X-Gm-Message-State: AOAM533qSGLp1qGtooeGP/VP8dW3qjr8bXGS2qB+17TpJntWAelYSvde kIoPgKljoD5YzZGiECIM224LL6IvDjE= X-Google-Smtp-Source: ABdhPJxC7oYCuORkoOOK4DUEzkYEfYLhGUnfZn9vDsPFZG+K9YzKeh2mopj6jvo7mzvfgOarCMOOvA== X-Received: by 2002:a17:902:a383:b029:e0:10e6:6ed7 with SMTP id x3-20020a170902a383b02900e010e66ed7mr14391547pla.5.1613372043468; Sun, 14 Feb 2021 22:54:03 -0800 (PST) Received: from Nuomi.localdomain (23.83.245.51.16clouds.com. [23.83.245.51]) by smtp.gmail.com with ESMTPSA id p17sm17232702pgn.38.2021.02.14.22.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 22:54:02 -0800 (PST) From: Nuo Mi To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Feb 2021 14:53:49 +0800 Message-Id: <20210215065349.9873-1-nuomi2021@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avformat/protocols: fix discard const compile warning 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: Nuo Mi Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" we keep an index in *opaque instead of a pointer. --- libavformat/protocols.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libavformat/protocols.c b/libavformat/protocols.c index 7df18fbb3b..530e78150d 100644 --- a/libavformat/protocols.c +++ b/libavformat/protocols.c @@ -111,17 +111,18 @@ const AVClass *ff_urlcontext_child_class_iterate(void **iter) const char *avio_enum_protocols(void **opaque, int output) { - const URLProtocol **p = *opaque; + const char* ret = NULL; + intptr_t i; - p = p ? p + 1 : url_protocols; - *opaque = p; - if (!*p) { - *opaque = NULL; - return NULL; + for (i = (intptr_t)*opaque; url_protocols[i]; i++) { + const URLProtocol *p = url_protocols[i]; + if ((output && p->url_write) || (!output && p->url_read)) { + ret = p->name; + break; + } } - if ((output && (*p)->url_write) || (!output && (*p)->url_read)) - return (*p)->name; - return avio_enum_protocols(opaque, output); + *opaque = (void*)(uintptr_t)(url_protocols[i] ? i + 1 : i); + return ret; } const AVClass *avio_protocol_get_class(const char *name)