On Tue, 3 Apr 2012, ron minnich wrote:

static void intel_init_display(struct drm_device *dev)
{
        struct drm_i915_private *dev_priv = dev->dev_private;

        /* Returns the core display clock speed */
        if (IS_I945G(dev) || (IS_G33(dev) && ! IS_PINEVIEW_M(dev)))
                dev_priv->display.get_display_clock_speed =
                        i945_get_display_clock_speed;
        else if (IS_I865G(dev))
                dev_priv->display.get_display_clock_speed =
                        i865_get_display_clock_speed;
        else if (IS_I85X(dev))
                dev_priv->display.get_display_clock_speed =
                        i855_get_display_clock_speed;
        else /* 852, 830 */
                dev_priv->display.get_display_clock_speed =
                        i830_get_display_clock_speed;
        if (something) {
                printf("some\n");
        } else if (IS_I865G(dev)) {
                printf("testin\n");
        }
}

I want to remove the IS_865G bits.

This does not quite work.
@@
identifier f;
type T;
@@
T f(...){<...

The T and f are strange. Are you going to want to say something more definite about the function name and type? If you don't care about them, it would be better to just leave them out.


-if (IS_I865G(...)) {...}

Since you don't have an else on the if, it will only match cases with a then. If you put else S for a metavariable S that is not used elsewhere, an isomorphism will let it match both the case with an else and without.

...>}
@@
identifier f;
type T;
statement S;
@@
T f(...){<...
-if (IS_I865G(...)) S;
...>}

@@ -18,7 +18,5 @@ static void intel_init_display(struct dr
                        i830_get_display_clock_speed;
        if (something) {
                printf("some\n");
-       } else if (IS_I865G(dev)) {
-               printf("testin\n");
-       }
+       } else {}
}
It misses the first one and I'm not sure I understand the addition of
the else {}?

It sees that what is in the else disappears, and so it adds the braces to be safe. It could be smarter to just remove the else, but I'm not sure if that information is easily available.

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to