On Mon, Aug 13, 2012 at 5:52 PM, Måns Rullgård <m...@mansr.com> wrote:
> aviad rozenhek <avia...@gmail.com> writes: > > > On Mon, Aug 13, 2012 at 1:18 PM, Måns Rullgård <m...@mansr.com> wrote: > > > >> aviad rozenhek <avia...@gmail.com> writes: > >> > >> >> > >> >> unary minus operator applied to unsigned type, result still unsigned > >> > > >> > I get this compiler warning when using any if the specialized > AVERROR_XXX > >> > macros, like AVERROR_BSF_NOT_FOUND or AVERROR_DECODER_NOT_FOUND. > >> > > >> > the reason is because > >> > > >> >> #define AVERROR_BSF_NOT_FOUND (-MKTAG(0xF8,'B','S','F')) ///< > >> >> Bitstream filter not found > >> > > >> > and the result from MKTAG is *unsigned* . > >> > >> Well, that's bad. > >> > >> > therefore I suggest to change the code thusly: > >> > > >> > #define DEFINE_AVERROR(a, b, c, d) (-(int32_t)MKTAG(a, b, c, d)) > >> > >> That conversion is undefined, so it's no good. The correct solution is > >> to define the error code in such a way that it is properly signed from > >> the start. MKTAG(-7,'B','S','F') might do it. > >> > >> > > hmm... If I read it correctly, MKTAG is unsigned by definition, > regardless > > of input > > > >> #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | > ((*unsigned*)(d) > >> << 24)) > > Sorry, I had the byte order mixed up. Anyway, adding even more casts > feels wrong. > > I think the problem is that a FourCC or tag is basically unsigned, while an AVError is negative. we could fix it by creating error tags using only 3 bytes [but having to deal with endianess] or just two bytes ...
_______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel