On Tue, Nov 03, 2020 at 04:56:16PM +0200, Sakari Ailus wrote: > On Tue, Nov 03, 2020 at 04:47:47PM +0200, Andy Shevchenko wrote: > > On Tue, Nov 03, 2020 at 03:34:00PM +0200, Sakari Ailus wrote: > > > Add a printk modifier %p4cc (for pixel format) for printing V4L2 and DRM > > > pixel formats denoted by fourccs. The fourcc encoding is the same for both > > > so the same implementation can be used. ... > > > + char output[sizeof("(xx)(xx)(xx)(xx) little-endian (0x01234567)")]; > > > > I would add a comment that there is another possibility, i.e. big-endian, but > > it occupies less space. > > This string is here to represent the longest possible output of the > function. Most of the time it's less. Saying that might make sense but it's > fairly clear already. Either way works for me though. It's not known by reading the above line. I would add a comment. ... > > > + p = special_hex_number(p, output + sizeof(output) - 2, *fourcc, > > > + sizeof(u32)); > > > > I would go with one line here. > > It's wrapped since the result would be over 80 otherwise. It will be not the first one breaking the limit in this module for the sake of readability. ... > > The (theoretical) problem is here that the case when buffer size is not enough > > to print a value will be like '(0xabc)' but should be rather '(0xabcd' like > > snprintf() does in general. Any comments here? Perhaps you need to add a comment to explain that the overflow is impossible. -- With Best Regards, Andy Shevchenko _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel