linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: avoid "mono_time_offset may be used uninitialized"
@ 2013-01-30  0:09 Stephen Warren
  2013-01-30 17:05 ` Stephen Warren
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Warren @ 2013-01-30  0:09 UTC (permalink / raw)
  To: David Airlie; +Cc: dri-devel, linux-kernel, Stephen Warren

From: Stephen Warren <swarren@nvidia.com>

Silence the following:
drivers/gpu/drm/drm_irq.c: In function 'drm_calc_vbltimestamp_from_scanoutpos':
drivers/gpu/drm/drm_irq.c:583:24: warning: 'mono_time_offset.tv64' may be used uninitialized in this function

... by always initializing mono_time_offset to zero. In practice, this
warning is false, since mono_time_offset is both set and used under the
condition if (!drm_timestamp_monotonic). However, at least my compiler
can't be coerced into realizing this; almost any code between the if
blocks that set and use the variable causes this warning.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
I'm not sure what the current thinking is re: silencing warnings like this;
IIRC some people may dislike this kind of change. Perhaps if this change
alone is problematic, one could additionally remove the if condition on the
use of mono_time_offset, thus always using the value?
---
 drivers/gpu/drm/drm_irq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 19c01ca..b199818 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -580,7 +580,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
 					  unsigned flags,
 					  struct drm_crtc *refcrtc)
 {
-	ktime_t stime, etime, mono_time_offset;
+	ktime_t stime, etime, mono_time_offset = {0};
 	struct timeval tv_etime;
 	struct drm_display_mode *mode;
 	int vbl_status, vtotal, vdisplay;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm: avoid "mono_time_offset may be used uninitialized"
  2013-01-30  0:09 [PATCH] drm: avoid "mono_time_offset may be used uninitialized" Stephen Warren
@ 2013-01-30 17:05 ` Stephen Warren
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Warren @ 2013-01-30 17:05 UTC (permalink / raw)
  To: David Airlie; +Cc: dri-devel, linux-kernel, Stephen Warren

On 01/29/2013 05:09 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> Silence the following:
> drivers/gpu/drm/drm_irq.c: In function 'drm_calc_vbltimestamp_from_scanoutpos':
> drivers/gpu/drm/drm_irq.c:583:24: warning: 'mono_time_offset.tv64' may be used uninitialized in this function

FYI, I found that I see this warning with gcc-4.5.3, but not with
gcc-4.7.2 or gcc-4.6.3. Hence, you might decide you don't care about
this patch.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-30 17:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-30  0:09 [PATCH] drm: avoid "mono_time_offset may be used uninitialized" Stephen Warren
2013-01-30 17:05 ` Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).