1. Aug 29, 2019
  2. Aug 27, 2019
    • Mauro Carvalho Chehab's avatar
      media: don't do a 31 bit shift on a signed int · 95c52069
      Mauro Carvalho Chehab authored
      
      
      On 32-bits archs, a signed integer has 31 bits plus on extra
      bit for signal. Due to that, touching the 32th bit with something
      like:
      
      	int bar = 1 << 31;
      
      has an undefined behavior in C on 32 bit architectures, as it
      touches the signal bit. This is warned by cppcheck.
      
      Instead, force the numbers to be unsigned, in order to solve this
      issue.
      
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      95c52069
    • Mauro Carvalho Chehab's avatar
      media: use the BIT() macro · cce8ccca
      Mauro Carvalho Chehab authored
      
      
      As warned by cppcheck:
      
      	[drivers/media/dvb-frontends/cx24123.c:434]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
      	[drivers/media/pci/bt8xx/bttv-input.c:87]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
      	[drivers/media/pci/bt8xx/bttv-input.c:98]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
      			...
      	[drivers/media/v4l2-core/v4l2-ioctl.c:1391]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
      
      There are lots of places where we're doing 1 << 31. That's bad,
      as, depending on the architecture, this has an undefined behavior.
      
      The BIT() macro is already prepared to handle this, so, let's
      just switch all "1 << number" macros by BIT(number) at the header files
      with has 1 << 31.
      
      Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> # exynos4-is and s3c-camif
      Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> # omap3isp, vsp1, xilinx, wl128x and ipu3
      Reviewed-by: Benoit Parrot <bparrot@ti.com> # am437x and ti-vpe
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      cce8ccca
    • Mauro Carvalho Chehab's avatar
      media: ov9650: add a sanity check · 093347ab
      Mauro Carvalho Chehab authored
      
      
      As pointed by cppcheck:
      
      	[drivers/media/i2c/ov9650.c:706]: (error) Shifting by a negative value is undefined behaviour
      	[drivers/media/i2c/ov9650.c:707]: (error) Shifting by a negative value is undefined behaviour
      	[drivers/media/i2c/ov9650.c:721]: (error) Shifting by a negative value is undefined behaviour
      
      Prevent mangling with gains with invalid values.
      
      As pointed by Sylvester, this should never happen in practice,
      as min value of V4L2_CID_GAIN control is 16 (gain is always >= 16
      and m is always >= 0), but it is too hard for a static analyzer
      to get this, as the logic with validates control min/max is
      elsewhere inside V4L2 core.
      
      Reviewed-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      093347ab
    • Mauro Carvalho Chehab's avatar
      media: aspeed-video: address a protential usage of an unitialized var · 31b8b0bd
      Mauro Carvalho Chehab authored
      
      
      While this might not occur in practice, if the device is doing
      the right thing, it would be teoretically be possible to have
      both hsync_counter and vsync_counter negatives.
      
      If this ever happen, ctrl will be undefined, but the driver
      will still call:
      
      	aspeed_video_update(video, VE_CTRL, 0, ctrl);
      
      Change the code to prevent this to happen.
      
      This was warned by cppcheck:
      
      	[drivers/media/platform/aspeed-video.c:653]: (error) Uninitialized variable: ctrl
      
      Reviewed-by: default avatarEddie James <eajames@linux.ibm.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      31b8b0bd
    • Mauro Carvalho Chehab's avatar
      media: vicodec: make life easier for static analyzers · cb804507
      Mauro Carvalho Chehab authored
      
      
      cppcheck incorrectly produces an error here:
      	[drivers/media/platform/vicodec/vicodec-core.c:1677]: (error) Pointer addition with NULL pointer.
      
      While this is actually a false positive, it doesn't hurt to
      reorder the checks to make the code simpler, handling first
      the error patch, where no color or alpha components are there.
      
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      cb804507
    • Mauro Carvalho Chehab's avatar
      media: remove include stdarg.h from some drivers · 59364e97
      Mauro Carvalho Chehab authored
      
      
      It doesn't make any sense to have gcc's stdarg.h included
      inside the Linux Kernel.
      
      Get rid of those includes.
      
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      59364e97
  3. Aug 26, 2019
  4. Aug 23, 2019
  5. Aug 22, 2019