Skip to contentSkip to conversation

drm: Reduce scope of 'state' variable

PATCH Superseded Dawid Kurek 2 participants 3 messages Jun 15, 2017

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm: Reduce scope of 'state' variable

Smaller scope reduces visibility of variable and makes usage of uninitialized variable less possible.

Changes in v2:
- separate declaration and initialization

---
 drivers/gpu/drm/drm_atomic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +2 -1
index f32506a..5e0d1e1 100644
@@ -108,9 +108,10 @@ struct drm_atomic_state *
 drm_atomic_state_alloc(struct drm_device *dev)
 {
 	struct drm_mode_config *config = &dev->mode_config;
-	struct drm_atomic_state *state;
 
 	if (!config->funcs->atomic_state_alloc) {
+		struct drm_atomic_state *state;
+
 		state = kzalloc(sizeof(*state), GFP_KERNEL);
 		if (!state)
 			return NULL;
Signature · 11 lines
2.10.0


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 5 lines · Dawid Kurek

Smaller scope reduces visibility of variable and makes usage of uninitialized variable less possible.

Changes in v2:
- separate declaration and initialization

Your patch is missing Signed-off-by tag

Sean

Quoted 27 lines
---
 drivers/gpu/drm/drm_atomic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +2 -1
index f32506a..5e0d1e1 100644
@@ -108,9 +108,10 @@ struct drm_atomic_state *
 drm_atomic_state_alloc(struct drm_device *dev)
 {
 	struct drm_mode_config *config = &dev->mode_config;
-	struct drm_atomic_state *state;
 
 	if (!config->funcs->atomic_state_alloc) {
+		struct drm_atomic_state *state;
+
 		state = kzalloc(sizeof(*state), GFP_KERNEL);
 		if (!state)
 			return NULL;
Signature · 6 lines
2.10.0


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
#2 lore raw
Quoted 9 lines · Sean Paul
Quoted 5 lines · Dawid Kurek

Smaller scope reduces visibility of variable and makes usage of uninitialized variable less possible.

Changes in v2:
- separate declaration and initialization

Your patch is missing Signed-off-by tag

Right... Missed it. v3 on the way.

Dawid

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel