Skip to contentSkip to conversation

i915: remove unneed NULL checks

PATCH In review Dan Carpenter 1 participant 2 messages Jun 23, 2010 – Aug 23, 2010

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

PATCH 1/1 i915: remove unneed NULL checks

We don't need to check the list cursor in a list_for_each_entry(). It's always non-null.

drivers/gpu/drm/i915/intel_display.c +2 -2
index cc8131f..8a2bdfc 100644
@@ -745,7 +745,7 @@ bool intel_pipe_has_type (struct drm_crtc *crtc, int type)
     struct drm_encoder *l_entry;
 
     list_for_each_entry(l_entry, &mode_config->encoder_list, head) {
-	    if (l_entry && l_entry->crtc == crtc) {
+	    if (l_entry->crtc == crtc) {
 		    struct intel_encoder *intel_encoder = enc_to_intel_encoder(l_entry);
 		    if (intel_encoder->type == type)
 			    return true;
@@ -3322,7 +3322,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
 
 	list_for_each_entry(encoder, &mode_config->encoder_list, head) {
 
-		if (!encoder || encoder->crtc != crtc)
+		if (encoder->crtc != crtc)
 			continue;
 
 		intel_encoder = enc_to_intel_encoder(encoder);
#1 lore raw
Quoted 3 lines · Dan Carpenter

We don't need to check the list cursor in a list_for_each_entry(). It's always non-null.

Here is another one that never got applied. I has a sad face. :(

regards,
dan carpenter

Quoted 24 lines
drivers/gpu/drm/i915/intel_display.c +2 -2
index cc8131f..8a2bdfc 100644
@@ -745,7 +745,7 @@ bool intel_pipe_has_type (struct drm_crtc *crtc, int type)
     struct drm_encoder *l_entry;
 
     list_for_each_entry(l_entry, &mode_config->encoder_list, head) {
-	    if (l_entry && l_entry->crtc == crtc) {
+	    if (l_entry->crtc == crtc) {
 		    struct intel_encoder *intel_encoder = enc_to_intel_encoder(l_entry);
 		    if (intel_encoder->type == type)
 			    return true;
@@ -3322,7 +3322,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
 
 	list_for_each_entry(encoder, &mode_config->encoder_list, head) {
 
-		if (!encoder || encoder->crtc != crtc)
+		if (encoder->crtc != crtc)
 			continue;
 
 		intel_encoder = enc_to_intel_encoder(encoder);