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 5FFEF48866 for ; Mon, 18 Dec 2023 22:18:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9B6F968D0D8; Tue, 19 Dec 2023 00:18:09 +0200 (EET) Received: from mail8.parnet.fi (mail8.parnet.fi [77.234.108.134]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9221968CF9B for ; Tue, 19 Dec 2023 00:18:03 +0200 (EET) Received: from mail9.parnet.fi (mail9.parnet.fi [77.234.108.21]) by mail8.parnet.fi with ESMTP id 3BIMI2ZM027571-3BIMI2ZN027571 for ; Tue, 19 Dec 2023 00:18:02 +0200 Received: from foo.martin.st (host-97-144.parnet.fi [77.234.97.144]) by mail9.parnet.fi (Postfix) with ESMTPS id DEBB5A146B; Tue, 19 Dec 2023 00:18:02 +0200 (EET) Date: Tue, 19 Dec 2023 00:18:02 +0200 (EET) From: =?ISO-8859-15?Q?Martin_Storsj=F6?= To: FFmpeg development discussions and patches , FFmpeg development discussions and patches In-Reply-To: Message-ID: <2043f241-f073-68e1-5994-c16c40e74b5c@martin.st> References: <20231218085426.3955262-1-martin@martin.st> <1984d539-957b-42cd-bc3b-27191f2f93f7@gmail.com> MIME-Version: 1.0 X-FE-Policy-ID: 3:14:2:SYSTEM X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Mon, 18 Dec 2023, Stefano Sabatini wrote: > 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. Pushed now, thanks! // Martin _______________________________________________ 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".