On Mon, 2005-06-27 at 15:56 -0400, Vladimir Dergachev wrote:
> I have been going through R300 drm source trying to implement all the 
> suggestions that people offerred.
> 
> I am having some hard time with 80 column rule. Now, in general, I agree 
> with it and it makes sense. However take a look at the following piece of 
> code:
> 
> /******** snip ***** line 264 r300_cmdbuf.c ********/
>       for(i=0;i<sz;i++){
>               values[i]=((int __user*)cmdbuf->buf)[i];
>               switch(r300_reg_flags[(reg>>2)+i]){
>                       case MARK_SAFE:
>                               break;
>                       case MARK_CHECK_OFFSET:
>                               if(r300_check_offset(dev_priv, (u32)values[i])){
>                                       DRM_ERROR("Offset failed range check 
> (reg=%04x sz=%d)\n", reg, sz);
>                                       return DRM_ERR(EINVAL);
>                                       }
>                               break;
> /******** snip ************************************/
> 
> To me it looks perfectly fine - we have a for cycle, a switch statement 
> inside and an error check in one of switch statement clauses. I don't see 
> how separating these out into other functions is going to improve 
> readability.
> 
> Problem is that there is no sane way I can fit the error message in 80 
> columns without being cryptic.

One common style for switch statements, especially with 8-space tabs, is
for the case statements to line up with the switch, rather than
indenting.  At the same time, I also would say that best effort to fit
in 80 columns is great, even if a couple of bits hang over.

Thanks!

-- 
Eric Anholt                                     [EMAIL PROTECTED]
http://people.freebsd.org/~anholt/              [EMAIL PROTECTED]


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to