Skip to contentSkip to conversation

drm/gma500: initialize gma_clock_t structures

PATCH RESEND Applied Arnd Bergmann 3 participants 7 messages Jan 16, 2018 – Jan 17, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 drm/gma500: initialize gma_clock_t structures

The two functions pass a partially initialized structure back to the caller after a memset() on the destination.

This is not entirely well-defined, most compilers are sensible enough to either keep the zero-initialization for the uninitialized members, but gcc-4.4 does not, and it warns about this:

drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_sdvo_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.dot' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_lvds_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.n' may be used uninitialized in this function

This adds an initialization at declaration time to avoid the warning and make it well-defined on all compiler versions.

---
Originally submitted on Sep 15, 2017, but got no reply. Resending unchanged.

---
 drivers/gpu/drm/gma500/oaktrail_crtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/gma500/oaktrail_crtc.c +2 -2
index 0fff269d3fe6..b49fe79c3f44 100644
@@ -134,7 +134,7 @@ static bool mrst_sdvo_find_best_pll(const struct gma_limit_t *limit,
 				    struct drm_crtc *crtc, int target,
 				    int refclk, struct gma_clock_t *best_clock)
 {
-	struct gma_clock_t clock;
+	struct gma_clock_t clock = {};
 	u32 target_vco, actual_freq;
 	s32 freq_error, min_error = 100000;
 
@@ -191,7 +191,7 @@ static bool mrst_lvds_find_best_pll(const struct gma_limit_t *limit,
 				    struct drm_crtc *crtc, int target,
 				    int refclk, struct gma_clock_t *best_clock)
 {
-	struct gma_clock_t clock;
+	struct gma_clock_t clock = {};
 	int err = target;
 
 	memset(best_clock, 0, sizeof(*best_clock));
Signature · 6 lines
2.9.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Arnd Bergmann

The two functions pass a partially initialized structure back to the caller after a memset() on the destination.

This is not entirely well-defined, most compilers are sensible enough to either keep the zero-initialization for the uninitialized members, but gcc-4.4 does not, and it warns about this:

drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_sdvo_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.dot' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_lvds_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.n' may be used uninitialized in this function

Quoted 4 lines

This adds an initialization at declaration time to avoid the warning and make it well-defined on all compiler versions.

Dave or Daniel, I'm on sick leave and will be for some time to come. Can one of you pick up this patch? Thanks.

Quoted 31 lines

---
Originally submitted on Sep 15, 2017, but got no reply. Resending unchanged.

---
 drivers/gpu/drm/gma500/oaktrail_crtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/gma500/oaktrail_crtc.c +2 -3
index 0fff269d3fe6..b49fe79c3f44 100644
@@ -134,7 +134,7 @@ static bool mrst_sdvo_find_best_pll(const struct gma_limit_t *limit,
                                    struct drm_crtc *crtc, int target,
                                    int refclk, struct gma_clock_t *best_clock)
 {
-       struct gma_clock_t clock;
+       struct gma_clock_t clock = {};
        u32 target_vco, actual_freq;
        s32 freq_error, min_error = 100000;
 
@@ -191,7 +191,7 @@ static bool mrst_lvds_find_best_pll(const struct gma_limit_t *limit,
                                    struct drm_crtc *crtc, int target,
                                    int refclk, struct gma_clock_t *best_clock)
 {
-       struct gma_clock_t clock;
+       struct gma_clock_t clock = {};
        int err = target;
 
        memset(best_clock, 0, sizeof(*best_clock));
--

2.9.0

#2 lore raw
In reply to Arnd Bergmann
Quoted 21 lines · Arnd Bergmann

The two functions pass a partially initialized structure back to the caller after a memset() on the destination.

This is not entirely well-defined, most compilers are sensible enough to either keep the zero-initialization for the uninitialized members, but gcc-4.4 does not, and it warns about this:

drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_sdvo_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.dot' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_lvds_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.n' may be used uninitialized in this function

Quoted 4 lines

This adds an initialization at declaration time to avoid the warning and make it well-defined on all compiler versions.

Applied to drm-misc-next-fixes for 4.16, thx for your patch. Aside: Still don't want commit rights? :-)

Cheers, Daniel

Quoted 35 lines

---
Originally submitted on Sep 15, 2017, but got no reply. Resending unchanged.

---
 drivers/gpu/drm/gma500/oaktrail_crtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/gma500/oaktrail_crtc.c +2 -2
index 0fff269d3fe6..b49fe79c3f44 100644
@@ -134,7 +134,7 @@ static bool mrst_sdvo_find_best_pll(const struct gma_limit_t *limit,
 				    struct drm_crtc *crtc, int target,
 				    int refclk, struct gma_clock_t *best_clock)
 {
-	struct gma_clock_t clock;
+	struct gma_clock_t clock = {};
 	u32 target_vco, actual_freq;
 	s32 freq_error, min_error = 100000;
 
@@ -191,7 +191,7 @@ static bool mrst_lvds_find_best_pll(const struct gma_limit_t *limit,
 				    struct drm_crtc *crtc, int target,
 				    int refclk, struct gma_clock_t *best_clock)
 {
-	struct gma_clock_t clock;
+	struct gma_clock_t clock = {};
 	int err = target;
 
 	memset(best_clock, 0, sizeof(*best_clock));
Signature · 6 lines
2.9.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Arnd Bergmann

The two functions pass a partially initialized structure back to the caller after a memset() on the destination.

This is not entirely well-defined, most compilers are sensible enough to either keep the zero-initialization for the uninitialized members, but gcc-4.4 does not, and it warns about this:

drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_sdvo_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.dot' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_lvds_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.n' may be used uninitialized in this function

Quoted 6 lines
Quoted 4 lines

This adds an initialization at declaration time to avoid the warning and make it well-defined on all compiler versions.

Applied to drm-misc-next-fixes for 4.16, thx for your patch.

Thanks!

Quoted 1 line

Aside: Still don't want commit rights? :-)

I think I'm fine without. While I do tend to have a backlog on DRM patches that I'd
like to get merged, they are generally of the kind that I should not apply myself
without the maintainer being involved in some form, and then they can commit it themselves.

Arnd

#4 lore raw
Quoted 32 lines · Arnd Bergmann
Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Arnd Bergmann

The two functions pass a partially initialized structure back to the caller after a memset() on the destination.

This is not entirely well-defined, most compilers are sensible enough to either keep the zero-initialization for the uninitialized members, but gcc-4.4 does not, and it warns about this:

drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_sdvo_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.dot' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_lvds_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.n' may be used uninitialized in this function

Quoted 6 lines
Quoted 4 lines

This adds an initialization at declaration time to avoid the warning and make it well-defined on all compiler versions.

Applied to drm-misc-next-fixes for 4.16, thx for your patch.

Thanks!

Quoted 8 lines
Quoted 1 line

Aside: Still don't want commit rights? :-)

I think I'm fine without. While I do tend to have a backlog on DRM patches that I'd
like to get merged, they are generally of the kind that I should not apply myself
without the maintainer being involved in some form, and then they can commit it themselves.

Commit rights isn't for pushing unreviewed stuff (our scripts will remind you of that if you try). But you could just volunteer someone to review the entire pile and then push it, instead of nagging every single slacking maintainer individually.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw
Quoted 42 lines · Daniel Vetter
Quoted 32 lines · Arnd Bergmann
Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Arnd Bergmann

The two functions pass a partially initialized structure back to the caller after a memset() on the destination.

This is not entirely well-defined, most compilers are sensible enough to either keep the zero-initialization for the uninitialized members, but gcc-4.4 does not, and it warns about this:

drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_sdvo_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.dot' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_lvds_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.n' may be used uninitialized in this function

Quoted 6 lines
Quoted 4 lines

This adds an initialization at declaration time to avoid the warning and make it well-defined on all compiler versions.

Applied to drm-misc-next-fixes for 4.16, thx for your patch.

Thanks!

Quoted 8 lines
Quoted 1 line

Aside: Still don't want commit rights? :-)

I think I'm fine without. While I do tend to have a backlog on DRM patches that I'd
like to get merged, they are generally of the kind that I should not apply myself
without the maintainer being involved in some form, and then they can commit it themselves.

Quoted 4 lines

Commit rights isn't for pushing unreviewed stuff (our scripts will remind you of that if you try). But you could just volunteer someone to review the entire pile and then push it, instead of nagging every single slacking maintainer individually.

I understand, but I could also just nag someone to review and apply the patches, right? Or do the committer and reviewer also need to be separate people?

Arnd

#6 lore raw
Quoted 43 lines · Arnd Bergmann
Quoted 42 lines · Daniel Vetter
Quoted 40 lines · Arnd Bergmann
Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Arnd Bergmann

The two functions pass a partially initialized structure back to the caller after a memset() on the destination.

This is not entirely well-defined, most compilers are sensible enough to either keep the zero-initialization for the uninitialized members, but gcc-4.4 does not, and it warns about this:

drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_sdvo_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.dot' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:175: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c: In function 'mrst_lvds_find_best_pll':
drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.vco' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.p2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m2' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.m1' may be used uninitialized in this function drivers/gpu/drm/gma500/oaktrail_crtc.c:208: warning: 'clock.n' may be used uninitialized in this function

Quoted 6 lines
Quoted 4 lines

This adds an initialization at declaration time to avoid the warning and make it well-defined on all compiler versions.

Applied to drm-misc-next-fixes for 4.16, thx for your patch.

Thanks!

Quoted 1 line

Aside: Still don't want commit rights? :-)

I think I'm fine without. While I do tend to have a backlog on DRM patches that I'd
like to get merged, they are generally of the kind that I should not apply myself
without the maintainer being involved in some form, and then they can commit it themselves.

Quoted 8 lines
Quoted 4 lines

Commit rights isn't for pushing unreviewed stuff (our scripts will remind you of that if you try). But you could just volunteer someone to review the entire pile and then push it, instead of nagging every single slacking maintainer individually.

I understand, but I could also just nag someone to review and apply the patches, right? Or do the committer and reviewer also need to be separate people?

Among author, committer and ackers/reviewers we just insist on 2 different people. So nagging works too, if you don't find that frustrating.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch