Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1589928

Re: [PATCH] [media] tw5864: use dev_warn instead of WARN to shut up warning

From Andrey Utkin <andrey.utkin@corp.bluecherry.net>
Newsgroups linux.kernel
Subject Re: [PATCH] [media] tw5864: use dev_warn instead of WARN to shut up warning
Date 2017-03-01 02:30 +0100
Message-ID <tg1fz-3Wb-3@gated-at.bofh.it> (permalink)
References <tfXlD-1rB-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Feb 28, 2017 at 10:14:37PM +0100, Arnd Bergmann wrote:
> tw5864_frameinterval_get() only initializes its output when it successfully
> identifies the video standard in tw5864_input. We get a warning here because
> gcc can't always track the state if initialized warnings across a WARN()
> macro, and thinks it might get used incorrectly in tw5864_s_parm:
> 
> media/pci/tw5864/tw5864-video.c: In function 'tw5864_s_parm':
> media/pci/tw5864/tw5864-video.c:816:38: error: 'time_base.numerator' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> media/pci/tw5864/tw5864-video.c:819:31: error: 'time_base.denominator' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> Using dev_warn() instead of WARN() avoids the __branch_check__() in
> unlikely and lets the compiler see that the initialization is correct.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks for the patch.
Acked-by: Andrey Utkin <andrey.utkin@corp.bluecherry.net>

See the note below.

> ---
>  drivers/media/pci/tw5864/tw5864-video.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c
> index 9421216bb942..4d9994a11c22 100644
> --- a/drivers/media/pci/tw5864/tw5864-video.c
> +++ b/drivers/media/pci/tw5864/tw5864-video.c
> @@ -717,6 +717,8 @@ static void tw5864_frame_interval_set(struct tw5864_input *input)
>  static int tw5864_frameinterval_get(struct tw5864_input *input,
>  				    struct v4l2_fract *frameinterval)
>  {
> +	struct tw5864_dev *dev = input->root;
> +
>  	switch (input->std) {
>  	case STD_NTSC:
>  		frameinterval->numerator = 1001;
> @@ -728,8 +730,8 @@ static int tw5864_frameinterval_get(struct tw5864_input *input,
>  		frameinterval->denominator = 25;
>  		break;
>  	default:
> -		WARN(1, "tw5864_frameinterval_get requested for unknown std %d\n",
> -		     input->std);
> +	        dev_warn(&dev->pci->dev, "tw5864_frameinterval_get requested for unknown std %d\n",
> +			 input->std);
>  		return -EINVAL;
>  	}

Looks good, though, arguably, it could fit 80 columns better if you put
the string literal to separate line.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] [media] tw5864: use dev_warn instead of WARN to shut up warning Arnd Bergmann <arnd@arndb.de> - 2017-02-28 22:20 +0100
  Re: [PATCH] [media] tw5864: use dev_warn instead of WARN to shut up  warning Andrey Utkin <andrey.utkin@corp.bluecherry.net> - 2017-03-01 02:30 +0100

csiph-web