From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4822646571 for ; Mon, 18 Dec 2023 22:08:52 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 90CC568CF10; Tue, 19 Dec 2023 00:08:50 +0200 (EET) Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8780C68CDD1 for ; Tue, 19 Dec 2023 00:08:44 +0200 (EET) Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-55365730863so1836662a12.1 for ; Mon, 18 Dec 2023 14:08:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702937323; x=1703542123; darn=ffmpeg.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:to:from:date:from:to:cc:subject:date:message-id :reply-to; bh=KJglUqNOBA+0SnTf7hohCj2at3ZPexuyFJqFbmvajgE=; b=NAbd9C/rZxdHOFlO7CyVpZ+44x82DnUzyTXARNeTSiyFB2fYwnolZOXzsQr/Jbwb8Y OTNQ2XnPzeVCp1pusRMfd2onAAKLHUcMApecIu0Cj5itzBhR26CgZ+vY42asN+1VFEOv EQiBfCBBn7ptiY/lwSS0wIKuPpSINpDQFdoxkH+APsyVHQufR+83kmasDwbPDc+kzUFO yh1iJhH8Ctx46VkoD3F9poURuvkM3S59KyVIt8laTe7XLyNimrp8qBfyYRe8eRTQeA0y 6fuqLmZnzd6h3/AjYmDW86Prz/ge0U+3fJwlwtYBfkBp0fXDi5fAm4LuiPrxj5sDfD7g s/zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702937323; x=1703542123; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KJglUqNOBA+0SnTf7hohCj2at3ZPexuyFJqFbmvajgE=; b=HkSLTGtDL1grZe+/I371eCDCEOCjNusD0hc2edBeYb8jbYlebEF9sVEhk3o5NKbCe/ PVO7m5lNb17wq5P7LeI1hVQsvdztfaI9zpvQEenJqTtn+Oa9eMiMdPd4Q0RjpadtmpfK cJr0PqiASRAQr4i/eXMdou3t5g37yKd9DfXtQX5nlnum+ad5e+dFQ8PI00LVwjfLx3y4 JEQfWe7/bKmotymv4GQJYiU1cgWOlth5Tc5ER+35F16mTSMI1S7fNfyiGkf+BVkcJygT k51uocmpUzSyveyQT8diSrXMNMw7in0cuUAFQr7cWSZ/j/Wr/bFkXYshu4U/GxS8j2Pq bbzA== X-Gm-Message-State: AOJu0YzRa6+Ec1f+PE0LnrF2mvlf93+ZYbbWP8DmMXz4Wtzoo/iCBnuv WopVyjAldOonqiO5GnWkru2cvP5yWL8= X-Google-Smtp-Source: AGHT+IEQ/o1b8iug8cz0yDFA8MhazW45e53YlriFDJqwTNEyzqlfBnR+hpCuP73hoOU/q/QXPorJ6A== X-Received: by 2002:a50:c8cb:0:b0:551:f72c:8ff8 with SMTP id k11-20020a50c8cb000000b00551f72c8ff8mr5572266edh.81.1702937322929; Mon, 18 Dec 2023 14:08:42 -0800 (PST) Received: from mariano (dynamic-adsl-84-220-189-10.clienti.tiscali.it. [84.220.189.10]) by smtp.gmail.com with ESMTPSA id et14-20020a056402378e00b005527cfaa2dfsm4548965edb.49.2023.12.18.14.08.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 14:08:42 -0800 (PST) Received: by mariano (Postfix, from userid 1000) id DE14DBFCDC; Mon, 18 Dec 2023 23:08:40 +0100 (CET) Date: Mon, 18 Dec 2023 23:08:40 +0100 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches References: <20231218085426.3955262-1-martin@martin.st> <1984d539-957b-42cd-bc3b-27191f2f93f7@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1984d539-957b-42cd-bc3b-27191f2f93f7@gmail.com> User-Agent: Mutt/2.1.4 (2021-12-11) Subject: Re: [FFmpeg-devel] [PATCH] gdigrab: Fix hwnd parameter issues X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On date Monday 2023-12-18 19:05:17 -0300, James Almer wrote: > On 12/18/2023 5:54 AM, Martin Storsj=F6 wrote: > > Converting from an integer to HWND (which is a pointer) requires > > an explicit cast, otherwise Clang errors out like this: > > = > > src/libavdevice/gdigrab.c:280:14: error: incompatible integer to p= ointer conversion assigning to 'HWND' (aka 'struct HWND__ *') from 'long' [= -Wint-conversion] > > 280 | hwnd =3D strtol(name, &p, 0); > > | ^ ~~~~~~~~~~~~~~~~~~~ > > = > > (With GCC and MSVC, this was a mere warning, but with recent Clang, > > this is an error.) > > = > > After adding a cast, all compilers also warn something like this: > > = > > src/libavdevice/gdigrab.c:280:16: warning: cast to 'HWND' (aka 'st= ruct HWND__ *') from smaller integer type 'long' [-Wint-to-pointer-cast] > > 280 | hwnd =3D (HWND) strtol(name, &p, 0); > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~ > > = > > On Windows, long types are 32 bit, so to get a usable pointer, we > > need to use long long. And interpret it as unsigned long long > > while at it - i.e. using strtoull. > > = > > Finally, right above it, the code triggered the following warning: > > = > > src/libavdevice/gdigrab.c:278:15: warning: mixing declarations and= code is incompatible with standards before C99 [-Wdeclaration-after-statem= ent] > > 278 | char *p; > > | ^ > > --- > > libavdevice/gdigrab.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > = > > diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c > > index 41ef370f2b..b2858ecd89 100644 > > --- a/libavdevice/gdigrab.c > > +++ b/libavdevice/gdigrab.c > > @@ -274,10 +274,10 @@ gdigrab_read_header(AVFormatContext *s1) > > } else if (!strcmp(filename, "desktop")) { > > hwnd =3D NULL; > > } else if (!strncmp(filename, "hwnd=3D", 5)) { > > - name =3D filename + 5; > > char *p; > > + name =3D filename + 5; > > - hwnd =3D strtol(name, &p, 0); > > + hwnd =3D (HWND) strtoull(name, &p, 0); > > if (p =3D=3D NULL || p =3D=3D name || p[0] =3D=3D '\0') > > { > = > Should be ok. Also LGTM, thanks. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".