> -----Original Message----- > From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of Guo, > Yejun > Sent: 2021年2月24日 23:15 > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/v4l2.c: fix build warning > > > > > -----Original Message----- > > From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of > Anton > > Khirnov > > Sent: 2021年2月24日 22:05 > > To: FFmpeg development discussions and patches > <ffmpeg-devel@ffmpeg.org> > > Subject: Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/v4l2.c: fix build > > warning > > > > Quoting Guo, Yejun (2021-02-20 08:22:11) > > > Here is the warning message: > > > src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’: > > > src/libavdevice/v4l2.c:1054:58: warning: ‘%s’ directive output may be > > truncated writing up to 255 bytes into a region of size 251 > > [-Wformat-truncation=] > > > snprintf(device_name, sizeof(device_name), "/dev/%s", > > entry->d_name); > > > ^~ > > > src/libavdevice/v4l2.c:1054:9: note: ‘snprintf’ output between 6 and 261 > > bytes into a destination of size 256 > > > snprintf(device_name, sizeof(device_name), "/dev/%s", > > entry->d_name); > > > > > > > > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > ~ > > > --- > > > This patch set fixes build warnings during make on my system with gcc > > > version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) with config option: > > > --disable-optimizations --enable-libx264 --enable-libx265 --enable-gpl > > --enable-libvpx --enable-libmfx > > --extra-cflags="-Wno-deprecated-declarations" > > > > > > I also tried '-Wall -Werror', there are many many issues starting from > > > configure. It is a long term task, let's fix one by one when have time. > > > > > > libavdevice/v4l2.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index > > > 365bacd771..15ade26eed 100644 > > > --- a/libavdevice/v4l2.c > > > +++ b/libavdevice/v4l2.c > > > @@ -1046,7 +1046,7 @@ static int v4l2_get_device_list(AVFormatContext > > *ctx, AVDeviceInfoList *device_l > > > return ret; > > > } > > > while ((entry = readdir(dir))) { > > > - char device_name[256]; > > > + char device_name[261]; > > > > sizeof(entry->d_name) + 5 > > would be eaiser to read IMO > > yes, will update the patches, and send all with V2 except patch 7 which has > been fixed with 1c9e53d7
just think we might better to use char device_name[512] which is more intuitive and it reserves the memory (local variable) in case that the following code is changed to add more chars. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".