[cairo] [PATCH] boilerplate: Maintain consistency in the usage of switch cases
Bryce W. Harrington
b.harrington at samsung.com
Tue May 6 10:24:18 PDT 2014
Thanks, applied.
On Mon, May 05, 2014 at 12:41:02PM +0530, RAVI NANJUNDAPPA wrote:
> Hello Bryce,
>
> Thanks for pointing out the trailing whitespaces. Since I'm using VI editor
> I've searched for the whitespaces
> (I've referred to the links provided by you) and removed them from the
> patch.
> The attached patch seems to be fine without these glitches.
> Please review the same and provide your inputs.
>
> Thanks and Best Regards,
> N Ravi
>
> > -----Original Message-----
> > From: Bryce W. Harrington [mailto:b.harrington at samsung.com]
> > Sent: Thursday, May 01, 2014 12:59 AM
> > To: Ravi Nanjundappa
> > Cc: cairo at cairographics.org
> > Subject: Re: [cairo] [PATCH] boilerplate: Maintain consistency in the
> usage of
> > switch cases
> >
> > On Tue, Apr 29, 2014 at 12:31:12PM +0530, Ravi Nanjundappa wrote:
> > > Some of the switch cases used in boilerplate are not consistent across
> > > other source files in the same module. This patch fixes the
> > > consistency issues of switch case usage in the boilerplate module.
> >
> > Hi Ravi, this looks good except there is some trailing whitespace added:
> >
> > humber:~/src/Cairo/cairo$ git am
> > /tmp/cairo_PATCH_boilerplate_Maintain_consistency_in_the_usage_of_sw
> > itch_cases.mbox
> > Applying: boilerplate: Maintain consistency in the usage of switch cases
> > /home/bryce/src/Cairo/cairo/.git/rebase-apply/patch:17: trailing
> > whitespace.
> > case CAIRO_CONTENT_ALPHA:
> > /home/bryce/src/Cairo/cairo/.git/rebase-apply/patch:18: trailing
> > whitespace.
> > format = CAIRO_FORMAT_A8;
> > /home/bryce/src/Cairo/cairo/.git/rebase-apply/patch:20: trailing
> > whitespace.
> > case CAIRO_CONTENT_COLOR:
> > /home/bryce/src/Cairo/cairo/.git/rebase-apply/patch:21: trailing
> > whitespace.
> > format = CAIRO_FORMAT_RGB24;
> > /home/bryce/src/Cairo/cairo/.git/rebase-apply/patch:23: trailing
> > whitespace.
> > case CAIRO_CONTENT_COLOR_ALPHA:
> > warning: squelched 22 whitespace errors
> > warning: 27 lines add whitespace errors.
> >
> > Could you re-post the patch with the trailing whitespace removed?
> >
> > Btw, in emacs, you can toggle on showing whitespace via:
> > M-x toggle-show-trailing-whitespace-show-ws
> >
> > Or to set it in your .emacs see:
> > http://stackoverflow.com/questions/11700934/emacs-set-and-toggle-
> > show-trailing-whitespace
> >
> > If you use vim, see:
> > http://stackoverflow.com/questions/4617059/showing-trailing-spaces-in-
> > vim
> >
> > If you're using a different editor, check the manual for that editor if it
> has a
> > way to show trailing whitespace.
> >
> > You can also have git help detect whitespace via:
> > git config --global core.whitespace trailing-space,space-before-tab
> >
> > Bryce
> >
> > > Signed-off-by: Ravi Nanjundappa <nravi.n at samsung.com>
> > > ---
> > > boilerplate/cairo-boilerplate-drm.c | 12 ++++++--
> > > boilerplate/cairo-boilerplate-xlib.c | 12 ++++++--
> > > boilerplate/cairo-boilerplate.c | 53
> ++++++++++++++++++++++++------
> > ----
> > > 3 files changed, 55 insertions(+), 22 deletions(-)
> > >
> > > diff --git a/boilerplate/cairo-boilerplate-drm.c
> > > b/boilerplate/cairo-boilerplate-drm.c
> > > index 214ce50..150cb0f 100644
> > > --- a/boilerplate/cairo-boilerplate-drm.c
> > > +++ b/boilerplate/cairo-boilerplate-drm.c
> > > @@ -52,10 +52,16 @@ _cairo_boilerplate_drm_create_surface (const char
> > *name,
> > > return NULL; /* skip tests if no supported h/w found */
> > >
> > > switch (content) {
> > > - case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
> > > - case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24;
> > break;
> > > + case CAIRO_CONTENT_ALPHA:
> > > + format = CAIRO_FORMAT_A8;
> > > + break;
> > > + case CAIRO_CONTENT_COLOR:
> > > + format = CAIRO_FORMAT_RGB24;
> > > + break;
> > > + case CAIRO_CONTENT_COLOR_ALPHA:
> > > default:
> > > - case CAIRO_CONTENT_COLOR_ALPHA: format =
> > CAIRO_FORMAT_ARGB32; break;
> > > + format = CAIRO_FORMAT_ARGB32;
> > > + break;
> > > }
> > >
> > > return *closure = cairo_drm_surface_create (device, format,
> > > width, height); diff --git a/boilerplate/cairo-boilerplate-xlib.c
> > > b/boilerplate/cairo-boilerplate-xlib.c
> > > index aed075f..f3d5598 100644
> > > --- a/boilerplate/cairo-boilerplate-xlib.c
> > > +++ b/boilerplate/cairo-boilerplate-xlib.c
> > > @@ -248,10 +248,16 @@ _cairo_boilerplate_xlib_create_similar
> > (cairo_surface_t *other,
> > > similar->dpy = cairo_xlib_surface_get_display (other);
> > >
> > > switch (content) {
> > > + case CAIRO_CONTENT_COLOR:
> > > + format = PictStandardRGB24;
> > > + break;
> > > + case CAIRO_CONTENT_ALPHA:
> > > + format = PictStandardA8;
> > > + break;
> > > + case CAIRO_CONTENT_COLOR_ALPHA:
> > > default:
> > > - case CAIRO_CONTENT_COLOR_ALPHA: format = PictStandardARGB32;
> > break;
> > > - case CAIRO_CONTENT_COLOR: format = PictStandardRGB24; break;
> > > - case CAIRO_CONTENT_ALPHA: format = PictStandardA8; break;
> > > + format = PictStandardARGB32;
> > > + break;
> > > }
> > >
> > > xrender_format = XRenderFindStandardFormat (similar->dpy,
> > > format); diff --git a/boilerplate/cairo-boilerplate.c
> > > b/boilerplate/cairo-boilerplate.c index 674c8d0..b8a6f74 100644
> > > --- a/boilerplate/cairo-boilerplate.c
> > > +++ b/boilerplate/cairo-boilerplate.c
> > > @@ -112,13 +112,19 @@ cairo_boilerplate_format_from_content
> > (cairo_content_t content)
> > > cairo_format_t format;
> > >
> > > switch (content) {
> > > - case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24;
> > break;
> > > - case CAIRO_CONTENT_COLOR_ALPHA: format =
> > CAIRO_FORMAT_ARGB32; break;
> > > - case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
> > > - default:
> > > - assert (0); /* not reached */
> > > - format = CAIRO_FORMAT_INVALID;
> > > - break;
> > > + case CAIRO_CONTENT_COLOR:
> > > + format = CAIRO_FORMAT_RGB24;
> > > + break;
> > > + case CAIRO_CONTENT_COLOR_ALPHA:
> > > + format = CAIRO_FORMAT_ARGB32;
> > > + break;
> > > + case CAIRO_CONTENT_ALPHA:
> > > + format = CAIRO_FORMAT_A8;
> > > + break;
> > > + default:
> > > + assert (0); /* not reached */
> > > + format = CAIRO_FORMAT_INVALID;
> > > + break;
> > > }
> > >
> > > return format;
> > > @@ -163,10 +169,16 @@ _cairo_boilerplate_image_create_similar
> > (cairo_surface_t *other,
> > > void *ptr;
> > >
> > > switch (content) {
> > > - case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
> > > - case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24;
> > break;
> > > + case CAIRO_CONTENT_ALPHA:
> > > + format = CAIRO_FORMAT_A8;
> > > + break;
> > > + case CAIRO_CONTENT_COLOR:
> > > + format = CAIRO_FORMAT_RGB24;
> > > + break;
> > > + case CAIRO_CONTENT_COLOR_ALPHA:
> > > default:
> > > - case CAIRO_CONTENT_COLOR_ALPHA: format =
> > CAIRO_FORMAT_ARGB32; break;
> > > + format = CAIRO_FORMAT_ARGB32;
> > > + break;
> > > }
> > >
> > > stride = cairo_format_stride_for_width(format, width); @@ -206,10
> > > +218,16 @@ _cairo_boilerplate_image16_create_similar (cairo_surface_t
> > *other,
> > > void *ptr;
> > >
> > > switch (content) {
> > > - case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
> > > - case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB16_565;
> > break;
> > > + case CAIRO_CONTENT_ALPHA:
> > > + format = CAIRO_FORMAT_A8;
> > > + break;
> > > + case CAIRO_CONTENT_COLOR:
> > > + format = CAIRO_FORMAT_RGB16_565;
> > > + break;
> > > + case CAIRO_CONTENT_COLOR_ALPHA:
> > > default:
> > > - case CAIRO_CONTENT_COLOR_ALPHA: format =
> > CAIRO_FORMAT_ARGB32; break;
> > > + format = CAIRO_FORMAT_ARGB32;
> > > + break;
> > > }
> > >
> > > stride = cairo_format_stride_for_width(format, width); @@ -681,10
> > > +699,13 @@ cairo_boilerplate_get_image_target (cairo_content_t
> > content)
> > > _cairo_boilerplate_register_all ();
> > >
> > > switch (content) {
> > > + case CAIRO_CONTENT_COLOR:
> > > + return &builtin_targets[1];
> > > + case CAIRO_CONTENT_COLOR_ALPHA:
> > > + return &builtin_targets[0];
> > > + case CAIRO_CONTENT_ALPHA:
> > > default:
> > > - case CAIRO_CONTENT_ALPHA: return NULL;
> > > - case CAIRO_CONTENT_COLOR: return &builtin_targets[1];
> > > - case CAIRO_CONTENT_COLOR_ALPHA: return &builtin_targets[0];
> > > + return NULL;
> > > }
> > > }
> > >
> > > --
> > > 1.7.9.5
> > >
> > > --
> > > cairo mailing list
> > > cairo at cairographics.org
> > > http://lists.cairographics.org/mailman/listinfo/cairo=
> [0;0m>From 4754db8c3d02dc52b0c044c42909ad6beebf3525 Mon Sep 17 00:00:00 2001[0;0m
> [0;0mFrom: Ravi Nanjundappa <nravi.n at samsung.com>[0;0m
> [0;0mDate: Mon, 5 May 2014 12:34:21 +0530[0;0m
> [0;0mSubject: [PATCH] boilerplate: Maintain consistency in the usage of switch[0;0m
> [0;0m cases[0;0m
> [0;0m[0;0m
> [0;0mSome of the switch cases used in boilerplate are not consistent[0;0m
> [0;0macross other source files in the same module. This patch fixes the[0;0m
> [0;0mconsistency issues of switch case usage in the boilerplate module.[0;0m
> [0;0m[0;0m
> [0;0mSigned-off-by: Ravi Nanjundappa <nravi.n at samsung.com>[0;0m
> [0;32m---[0;0m
> [0;0m boilerplate/cairo-boilerplate-drm.c | 12 ++++++--[0;0m
> [0;0m boilerplate/cairo-boilerplate-xlib.c | 12 ++++++--[0;0m
> [0;0m boilerplate/cairo-boilerplate.c | 53 ++++++++++++++++++++++++----------[0;0m
> [0;0m 3 files changed, 55 insertions(+), 22 deletions(-)[0;0m
> [0;0m[0;0m
> [0;34mdiff --git a/boilerplate/cairo-boilerplate-drm.c b/boilerplate/cairo-boilerplate-drm.c[0;0m
> [0;0mindex 214ce50..79d9229 100644[0;0m
> [0;32m--- a/boilerplate/cairo-boilerplate-drm.c[0;0m
> [1;32m+++ b/boilerplate/cairo-boilerplate-drm.c[0;0m
> [1;34m@@ -52,10 +52,16 @@ _cairo_boilerplate_drm_create_surface (const char *name,[0;0m
> [0;0m return NULL; /* skip tests if no supported h/w found */[0;0m
> [0;0m [0;0m
> [0;0m switch (content) {[0;0m
> [0;32m- case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break;[0;0m
> [1;32m+ case CAIRO_CONTENT_ALPHA:[0;0m
> [1;32m+ format = CAIRO_FORMAT_A8;[0;0m
> [1;32m+ break;[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR:[0;0m
> [1;32m+ format = CAIRO_FORMAT_RGB24;[0;0m
> [1;32m+ break;[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR_ALPHA:[0;0m
> [0;0m default:[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;[0;0m
> [1;32m+ format = CAIRO_FORMAT_ARGB32;[0;0m
> [1;32m+ break;[0;0m
> [0;0m }[0;0m
> [0;0m [0;0m
> [0;0m return *closure = cairo_drm_surface_create (device, format, width, height);[0;0m
> [0;34mdiff --git a/boilerplate/cairo-boilerplate-xlib.c b/boilerplate/cairo-boilerplate-xlib.c[0;0m
> [0;0mindex aed075f..f3d5598 100644[0;0m
> [0;32m--- a/boilerplate/cairo-boilerplate-xlib.c[0;0m
> [1;32m+++ b/boilerplate/cairo-boilerplate-xlib.c[0;0m
> [1;34m@@ -248,10 +248,16 @@ _cairo_boilerplate_xlib_create_similar (cairo_surface_t *other,[0;0m
> [0;0m similar->dpy = cairo_xlib_surface_get_display (other);[0;0m
> [0;0m [0;0m
> [0;0m switch (content) {[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR:[0;0m
> [1;32m+ format = PictStandardRGB24;[0;0m
> [1;32m+ break;[0;0m
> [1;32m+ case CAIRO_CONTENT_ALPHA:[0;0m
> [1;32m+ format = PictStandardA8;[0;0m
> [1;32m+ break;[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR_ALPHA:[0;0m
> [0;0m default:[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR_ALPHA: format = PictStandardARGB32; break;[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR: format = PictStandardRGB24; break;[0;0m
> [0;32m- case CAIRO_CONTENT_ALPHA: format = PictStandardA8; break;[0;0m
> [1;32m+ format = PictStandardARGB32;[0;0m
> [1;32m+ break;[0;0m
> [0;0m }[0;0m
> [0;0m [0;0m
> [0;0m xrender_format = XRenderFindStandardFormat (similar->dpy, format);[0;0m
> [0;34mdiff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c[0;0m
> [0;0mindex 674c8d0..97d624c 100644[0;0m
> [0;32m--- a/boilerplate/cairo-boilerplate.c[0;0m
> [1;32m+++ b/boilerplate/cairo-boilerplate.c[0;0m
> [1;34m@@ -112,13 +112,19 @@ cairo_boilerplate_format_from_content (cairo_content_t content)[0;0m
> [0;0m cairo_format_t format;[0;0m
> [0;0m [0;0m
> [0;0m switch (content) {[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break;[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;[0;0m
> [0;32m- case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;[0;0m
> [0;32m- default:[0;0m
> [0;32m- assert (0); /* not reached */[0;0m
> [0;32m- format = CAIRO_FORMAT_INVALID;[0;0m
> [0;32m- break;[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR:[0;0m
> [1;32m+ format = CAIRO_FORMAT_RGB24;[0;0m
> [1;32m+ break;[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR_ALPHA:[0;0m
> [1;32m+ format = CAIRO_FORMAT_ARGB32;[0;0m
> [1;32m+ break;[0;0m
> [1;32m+ case CAIRO_CONTENT_ALPHA:[0;0m
> [1;32m+ format = CAIRO_FORMAT_A8;[0;0m
> [1;32m+ break;[0;0m
> [1;32m+ default:[0;0m
> [1;32m+ assert (0); /* not reached */[0;0m
> [1;32m+ format = CAIRO_FORMAT_INVALID;[0;0m
> [1;32m+ break;[0;0m
> [0;0m }[0;0m
> [0;0m [0;0m
> [0;0m return format;[0;0m
> [1;34m@@ -163,10 +169,16 @@ _cairo_boilerplate_image_create_similar (cairo_surface_t *other,[0;0m
> [0;0m void *ptr;[0;0m
> [0;0m [0;0m
> [0;0m switch (content) {[0;0m
> [0;32m- case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break;[0;0m
> [1;32m+ case CAIRO_CONTENT_ALPHA:[0;0m
> [1;32m+ format = CAIRO_FORMAT_A8;[0;0m
> [1;32m+ break;[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR:[0;0m
> [1;32m+ format = CAIRO_FORMAT_RGB24;[0;0m
> [1;32m+ break;[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR_ALPHA:[0;0m
> [0;0m default:[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;[0;0m
> [1;32m+ format = CAIRO_FORMAT_ARGB32;[0;0m
> [1;32m+ break;[0;0m
> [0;0m }[0;0m
> [0;0m [0;0m
> [0;0m stride = cairo_format_stride_for_width(format, width);[0;0m
> [1;34m@@ -206,10 +218,16 @@ _cairo_boilerplate_image16_create_similar (cairo_surface_t *other,[0;0m
> [0;0m void *ptr;[0;0m
> [0;0m [0;0m
> [0;0m switch (content) {[0;0m
> [0;32m- case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB16_565; break;[0;0m
> [1;32m+ case CAIRO_CONTENT_ALPHA:[0;0m
> [1;32m+ format = CAIRO_FORMAT_A8;[0;0m
> [1;32m+ break;[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR:[0;0m
> [1;32m+ format = CAIRO_FORMAT_RGB16_565;[0;0m
> [1;32m+ break;[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR_ALPHA:[0;0m
> [0;0m default:[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;[0;0m
> [1;32m+ format = CAIRO_FORMAT_ARGB32;[0;0m
> [1;32m+ break;[0;0m
> [0;0m }[0;0m
> [0;0m [0;0m
> [0;0m stride = cairo_format_stride_for_width(format, width);[0;0m
> [1;34m@@ -681,10 +699,13 @@ cairo_boilerplate_get_image_target (cairo_content_t content)[0;0m
> [0;0m _cairo_boilerplate_register_all ();[0;0m
> [0;0m [0;0m
> [0;0m switch (content) {[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR:[0;0m
> [1;32m+ return &builtin_targets[1];[0;0m
> [1;32m+ case CAIRO_CONTENT_COLOR_ALPHA:[0;0m
> [1;32m+ return &builtin_targets[0];[0;0m
> [1;32m+ case CAIRO_CONTENT_ALPHA:[0;0m
> [0;0m default:[0;0m
> [0;32m- case CAIRO_CONTENT_ALPHA: return NULL;[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR: return &builtin_targets[1];[0;0m
> [0;32m- case CAIRO_CONTENT_COLOR_ALPHA: return &builtin_targets[0];[0;0m
> [1;32m+ return NULL;[0;0m
> [0;0m }[0;0m
> [0;0m }[0;0m
> [0;0m [0;0m
> [0;32m-- [0;0m
> [0;0m1.7.9.5[0;0m
> [0;0m[0;0m
More information about the cairo
mailing list