staging: bcm2835-camera: Avoid unneeded internal declaration warning
Subsystems (3)
PATCH 1/1 staging: bcm2835-camera: Avoid unneeded internal declaration warning
Clang warns:
drivers/staging/vc04_services/bcm2835-camera/controls.c:59:18: warning:
variable 'mains_freq_qmenu' is not needed and will not be emitted [-Wunneeded-internal-declaration]
static const s64 mains_freq_qmenu[] = {
^1 warning generated.
This is because mains_freq_qmenu is currently only used in an ARRAY_SIZE macro, which is a compile time evaluation in this case. Avoid this by adding mains_freq_qmenu as the imenu member of this structure, which matches all other controls that uses the ARRAY_SIZE macro in v4l2_ctrls. This turns out to be a no-op because V4L2_CID_MPEG_VIDEO_BITRATE_MODE is defined as a MMAL_CONTROL_TYPE_STD_MENU, which does not pass the imenu definition along to v4l2_ctrl_new in bm2835_mmal_init_controls.
--- drivers/staging/vc04_services/bcm2835-camera/controls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/bcm2835-camera/controls.c +1 -1
@@ -1106,7 +1106,7 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { {V4L2_CID_POWER_LINE_FREQUENCY ,MMAL_CONTROL_TYPE_STD_MENU ,0 ,ARRAY_SIZE (mains_freq_qmenu) -1 , -1 ,1 ,NULL , +1 ,1 , mains_freq_qmenu,MMAL_PARAMETER_FLICKER_AVOID , &ctrl_set_flicker_avoidance, false
Signature · 1 line
2.19.0
Hi Nate
Thanks for the patch.
Quoted 10 lines · Nathan Chancellor
Clang warns:
drivers/staging/vc04_services/bcm2835-camera/controls.c:59:18: warning:
variable 'mains_freq_qmenu' is not needed and will not be emitted [-Wunneeded-internal-declaration]static const s64 mains_freq_qmenu[] = { ^1 warning generated.
Quoted 7 lines
This is because
mains_freq_qmenuis currently only used in anARRAY_SIZEmacro, which is a compile time evaluation in this case. Avoid this by addingmains_freq_qmenuas the imenu member of this structure, which matches all other controls that uses theARRAY_SIZEmacro inv4l2_ctrls. This turns out to be a no-op becauseV4L2_CID_MPEG_VIDEO_BITRATE_MODEis defined as aMMAL_CONTROL_TYPE_STD_MENU, which does not pass the imenu definition along tov4l2_ctrl_newinbm2835_mmal_init_controls.
There's a slight confusion betwen V4L2_CID_MPEG_VIDEO_BITRATE_MODE and V4L2_CID_POWER_LINE_FREQUENCY in your description.
However you're right that MMAL_CONTROL_TYPE_STD_MENU calls v4l2_ctrl_new_std_menu which doesn't need a menu array (it's v4l2_ctrl_new_int_menu that does). That means the correct fix is to define the max value using the relevant enum (in this case V4L2_CID_POWER_LINE_FREQUENCY_AUTO) and remove the array.
The same is true for V4L2_CID_MPEG_VIDEO_BITRATE_MODE - max should be V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, and remove the bitrate_mode_qmenu array.
Thanks,
Dave
Quoted 27 lines
Signed-off-by Nathan Chancellor <[email protected]>--- drivers/staging/vc04_services/bcm2835-camera/controls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/vc04_services/bcm2835-camera/controls.c +1
-2@@ -1106,7 +1106,7 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { {V4L2_CID_POWER_LINE_FREQUENCY ,MMAL_CONTROL_TYPE_STD_MENU ,0 ,ARRAY_SIZE (mains_freq_qmenu) -1 , -1 ,1 ,NULL , +1 ,1 , mains_freq_qmenu,MMAL_PARAMETER_FLICKER_AVOID , &ctrl_set_flicker_avoidance, false --2.19.0
_______________________________________________
linux-rpi-kernel mailing list
linux-rpi-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel
Quoted 33 lines · Dave Stevenson
Hi Nate
Thanks for the patch.
Quoted 10 lines · Nathan Chancellor
Clang warns:
drivers/staging/vc04_services/bcm2835-camera/controls.c:59:18: warning:
variable 'mains_freq_qmenu' is not needed and will not be emitted [-Wunneeded-internal-declaration]static const s64 mains_freq_qmenu[] = { ^1 warning generated.
Quoted 7 lines
This is because
mains_freq_qmenuis currently only used in anARRAY_SIZEmacro, which is a compile time evaluation in this case. Avoid this by addingmains_freq_qmenuas the imenu member of this structure, which matches all other controls that uses theARRAY_SIZEmacro inv4l2_ctrls. This turns out to be a no-op becauseV4L2_CID_MPEG_VIDEO_BITRATE_MODEis defined as aMMAL_CONTROL_TYPE_STD_MENU, which does not pass the imenu definition along tov4l2_ctrl_newinbm2835_mmal_init_controls.There's a slight confusion betwen
V4L2_CID_MPEG_VIDEO_BITRATE_MODEandV4L2_CID_POWER_LINE_FREQUENCYin your description.However you're right that
MMAL_CONTROL_TYPE_STD_MENUcallsv4l2_ctrl_new_std_menuwhich doesn't need a menu array (it'sv4l2_ctrl_new_int_menuthat does). That means the correct fix is to define the max value using the relevant enum (in this caseV4L2_CID_POWER_LINE_FREQUENCY_AUTO) and remove the array.
Quoted 7 lines
The same is true for
V4L2_CID_MPEG_VIDEO_BITRATE_MODE- max should beV4L2_MPEG_VIDEO_BITRATE_MODE_CBR, and remove thebitrate_mode_qmenuarray.Thanks,
Dave
Hi Dave,
Thank you for the review, I appreciate it. I had certainly considered that solution first butnfigured this was the more conservative change.
I will send a v2 soon with the suggested change.
Nathan
Quoted 27 lines
Quoted 27 lines
Signed-off-by Nathan Chancellor <[email protected]>--- drivers/staging/vc04_services/bcm2835-camera/controls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/vc04_services/bcm2835-camera/controls.c +1
-2@@ -1106,7 +1106,7 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { {V4L2_CID_POWER_LINE_FREQUENCY ,MMAL_CONTROL_TYPE_STD_MENU ,0 ,ARRAY_SIZE (mains_freq_qmenu) -1 , -1 ,1 ,NULL , +1 ,1 , mains_freq_qmenu,MMAL_PARAMETER_FLICKER_AVOID , &ctrl_set_flicker_avoidance, false --2.19.0
_______________________________________________
linux-rpi-kernel mailing list
linux-rpi-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel