Bastiaan Timmer
2012-May-07 22:48 UTC
[flac-dev] [PATCH] Add missing functions to VorbisComment class + a few other things
> While you are at it, can you check/fix the following warning > ? > > metadata.cpp:812:98: warning: narrowing conversion of > 'strlen(((const > char*)string))' from 'size_t {aka long unsigned int}' to > 'FLAC__uint32 > {aka unsigned int}' inside { } is ill-formed in C++11 > [-Wnarrowing] > > > Thanks !Yeah sure! I don't get that error because I'm on a 32 bit OS by the way. The message makes it pretty clear you are compiling on 64 bit, so the size_t returned by strlen is 64 bits, but FLAC__StreamMetadata_VorbisComment_Entry expects a FLAC__uint32 (which is obviously 32 bits), so gcc warns/errors that the size_t might not fit. I can think of two solutions: 1. Make the FLAC__StreamMetadata_VorbisComment_Entry struct's 'length' member a FLAC__uint64. 2. static_cast the return value of strlen to 32 bits... I'd say option 2 is easiest, as I don't know what else will be affected by changing the size of FLAC__StreamMetadata_VorbisComment_Entry. The only problem with option 2 would be if the vendor string ever gets larger than ~4.3 billion characters, but I don't think vorbis comments support values that large anyway. Anyway, here's a patch that casts to FLAC__uint32, Note I have the offending code on a very different line number (current git I think), so this patch may not apply cleanly. But it's a one-liner anyway (a one-worder actually), so you could just read it and apply it manually... Also, I don't know if such a cast is considered an expensive operation, but in that case it might be possible to first check the size of size_t (during preprocessing) to see if it is larger than 32 bits. The cast is unnecessary if it is not. Bas -------------- next part -------------- A non-text attachment was scrubbed... Name: narrowing_patch Type: application/octet-stream Size: 800 bytes Desc: not available Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20120507/8342f893/attachment-0001.obj
Erik de Castro Lopo
2012-May-08 10:11 UTC
[flac-dev] [PATCH] Add missing functions to VorbisComment class + a few other things
Bastiaan Timmer wrote:> Anyway, here's a patch that casts to FLAC__uint32,Applied. Thanks. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
Reasonably Related Threads
- [PATCH] Add missing functions to VorbisComment class + a few other things
- [PATCH] Add missing functions to VorbisComment class + a few other things
- Patch to improve malformed vorbiscomment handling
- 64-bit FLAC structure sizes and padding
- Patch to improve malformed vorbiscomment handling