Skip to content

Commit 3a75e84

Browse files
committed
Added braces
1 parent 9f2773b commit 3a75e84

14 files changed

Lines changed: 78 additions & 50 deletions

File tree

src/_imaging.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,9 @@ getpixel(Imaging im, ImagingAccess access, int x, int y)
490490
case IMAGING_TYPE_FLOAT32:
491491
return PyFloat_FromDouble(pixel.f);
492492
case IMAGING_TYPE_SPECIAL:
493-
if (strncmp(im->mode, "I;16", 4) == 0)
493+
if (strncmp(im->mode, "I;16", 4) == 0) {
494494
return PyLong_FromLong(pixel.h);
495+
}
495496
break;
496497
}
497498

@@ -1456,8 +1457,9 @@ _point(ImagingObject* self, PyObject* args)
14561457
lut[i*4] = CLIP8(data[i]);
14571458
lut[i*4+1] = CLIP8(data[i+256]);
14581459
lut[i*4+2] = CLIP8(data[i+512]);
1459-
if (n > 768)
1460+
if (n > 768) {
14601461
lut[i*4+3] = CLIP8(data[i+768]);
1462+
}
14611463
}
14621464
im = ImagingPoint(self->image, mode, (void*) lut);
14631465
} else {
@@ -1523,16 +1525,18 @@ _putdata(ImagingObject* self, PyObject* args)
15231525
/* Plain string data */
15241526
for (i = y = 0; i < n; i += image->xsize, y++) {
15251527
x = n - i;
1526-
if (x > (int) image->xsize)
1528+
if (x > (int) image->xsize) {
15271529
x = image->xsize;
1530+
}
15281531
memcpy(image->image8[y], p+i, x);
15291532
}
15301533
} else {
15311534
/* Scaled and clipped string data */
15321535
for (i = x = y = 0; i < n; i++) {
15331536
image->image8[y][x] = CLIP8((int) (p[i] * scale + offset));
1534-
if (++x >= (int) image->xsize)
1537+
if (++x >= (int) image->xsize) {
15351538
x = 0, y++;
1539+
}
15361540
}
15371541
}
15381542
} else {
@@ -1932,12 +1936,14 @@ im_setmode(ImagingObject* self, PyObject* args)
19321936
/* color to color */
19331937
strcpy(im->mode, mode);
19341938
im->bands = modelen;
1935-
if (!strcmp(mode, "RGBA"))
1939+
if (!strcmp(mode, "RGBA")) {
19361940
(void) ImagingFillBand(im, 3, 255);
1941+
}
19371942
} else {
19381943
/* trying doing an in-place conversion */
1939-
if (!ImagingConvertInPlace(im, mode))
1944+
if (!ImagingConvertInPlace(im, mode)) {
19401945
return NULL;
1946+
}
19411947
}
19421948

19431949
if (self->access) {

src/_imagingft.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,11 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *
406406

407407
direction = RAQM_DIRECTION_DEFAULT;
408408
if (dir) {
409-
if (strcmp(dir, "rtl") == 0)
409+
if (strcmp(dir, "rtl") == 0) {
410410
direction = RAQM_DIRECTION_RTL;
411-
else if (strcmp(dir, "ltr") == 0)
411+
} else if (strcmp(dir, "ltr") == 0) {
412412
direction = RAQM_DIRECTION_LTR;
413-
else if (strcmp(dir, "ttb") == 0) {
413+
} else if (strcmp(dir, "ttb") == 0) {
414414
direction = RAQM_DIRECTION_TTB;
415415
if (p_raqm.version_atleast == NULL || !(*p_raqm.version_atleast)(0, 7, 0)) {
416416
PyErr_SetString(PyExc_ValueError, "libraqm 0.7 or greater required for 'ttb' direction");
@@ -694,8 +694,9 @@ font_getsize(FontObject* self, PyObject* args)
694694
offset = -glyph_info[i].y_advance -
695695
face->glyph->metrics.height -
696696
face->glyph->metrics.vertBearingY;
697-
if (offset < 0)
697+
if (offset < 0) {
698698
y_max -= offset;
699+
}
699700
}
700701

701702
if (bbox.xMax > x_max) {

src/encode.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,9 @@ PyImaging_JpegEncoderNew(PyObject* self, PyObject* args)
10851085
if (extra && extra_size > 0) {
10861086
/* malloc check ok, length is from python parsearg */
10871087
char* p = malloc(extra_size); // Freed in JpegEncode, Case 5
1088-
if (!p)
1088+
if (!p) {
10891089
return PyErr_NoMemory();
1090+
}
10901091
memcpy(p, extra, extra_size);
10911092
extra = p;
10921093
} else {
@@ -1097,7 +1098,9 @@ PyImaging_JpegEncoderNew(PyObject* self, PyObject* args)
10971098
/* malloc check ok, length is from python parsearg */
10981099
char* pp = malloc(rawExifLen); // Freed in JpegEncode, Case 5
10991100
if (!pp) {
1100-
if (extra) free(extra);
1101+
if (extra) {
1102+
free(extra);
1103+
}
11011104
return PyErr_NoMemory();
11021105
}
11031106
memcpy(pp, rawExif, rawExifLen);

src/libImaging/Convert.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,17 +1660,16 @@ convert(Imaging imOut, Imaging imIn, const char *mode,
16601660
}
16611661
}
16621662

1663-
if (!convert)
1663+
if (!convert) {
16641664
#ifdef notdef
16651665
return (Imaging) ImagingError_ValueError("conversion not supported");
16661666
#else
1667-
{
1668-
static char buf[256];
1669-
/* FIXME: may overflow if mode is too large */
1670-
sprintf(buf, "conversion from %s to %s not supported", imIn->mode, mode);
1671-
return (Imaging) ImagingError_ValueError(buf);
1672-
}
1667+
static char buf[256];
1668+
/* FIXME: may overflow if mode is too large */
1669+
sprintf(buf, "conversion from %s to %s not supported", imIn->mode, mode);
1670+
return (Imaging) ImagingError_ValueError(buf);
16731671
#endif
1672+
}
16741673

16751674
imOut = ImagingNew2Dirty(mode, imOut, imIn);
16761675
if (!imOut) {

src/libImaging/Crop.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ ImagingCrop(Imaging imIn, int sx0, int sy0, int sx1, int sy1)
3232
}
3333

3434
xsize = sx1 - sx0;
35-
if (xsize < 0)
35+
if (xsize < 0) {
3636
xsize = 0;
37+
}
3738
ysize = sy1 - sy0;
38-
if (ysize < 0)
39+
if (ysize < 0) {
3940
ysize = 0;
41+
}
4042

4143
imOut = ImagingNewDirty(imIn->mode, xsize, ysize);
4244
if (!imOut) {

src/libImaging/Draw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,8 +941,9 @@ ellipse(Imaging im, int x0, int y0, int x1, int y1,
941941
}
942942
lx = x, ly = y;
943943
}
944-
if (n == 0)
944+
if (n == 0) {
945945
return 0;
946+
}
946947

947948
if (inner) {
948949
// Inner circle

src/libImaging/GetBBox.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ ImagingGetBBox(Imaging im, int bbox[4])
3939
for (x = 0; x < im->xsize; x++) {\
4040
if (im->image[y][x] & mask) {\
4141
has_data = 1;\
42-
if (x < bbox[0])\
42+
if (x < bbox[0]) {\
4343
bbox[0] = x;\
44-
if (x >= bbox[2])\
44+
}\
45+
if (x >= bbox[2]) {\
4546
bbox[2] = x+1;\
47+
}\
4648
}\
4749
}\
4850
if (has_data) {\
49-
if (bbox[1] < 0)\
50-
bbox[1] = y;\
51+
if (bbox[1] < 0) {\
52+
bbox[1] = y;\
53+
}\
5154
bbox[3] = y+1;\
5255
}\
5356
}

src/libImaging/GifDecode.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252
default:\
5353
return -1;\
5454
}\
55-
if (state->y < state->ysize)\
55+
if (state->y < state->ysize) {\
5656
out = im->image8[state->y + state->yoff] + state->xoff;\
57+
}\
5758
}
5859

5960

@@ -70,24 +71,25 @@ ImagingGifDecode(Imaging im, ImagingCodecState state, UINT8* buffer, Py_ssize_t
7071

7172
if (!state->state) {
7273

73-
/* Initialise state */
74-
if (context->bits < 0 || context->bits > 12) {
75-
state->errcode = IMAGING_CODEC_CONFIG;
76-
return -1;
77-
}
74+
/* Initialise state */
75+
if (context->bits < 0 || context->bits > 12) {
76+
state->errcode = IMAGING_CODEC_CONFIG;
77+
return -1;
78+
}
7879

79-
/* Clear code */
80-
context->clear = 1 << context->bits;
80+
/* Clear code */
81+
context->clear = 1 << context->bits;
8182

82-
/* End code */
83-
context->end = context->clear + 1;
83+
/* End code */
84+
context->end = context->clear + 1;
8485

85-
/* Interlace */
86-
if (context->interlace) {
87-
context->interlace = 1;
88-
context->step = context->repeat = 8;
89-
} else
90-
context->step = 1;
86+
/* Interlace */
87+
if (context->interlace) {
88+
context->interlace = 1;
89+
context->step = context->repeat = 8;
90+
} else {
91+
context->step = 1;
92+
}
9193

9294
state->state = 1;
9395
}

src/libImaging/Histo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ ImagingGetHistogram(Imaging im, Imaging imMask, void* minmax)
179179
FLOAT32* in = (FLOAT32*) im->image32[y];
180180
for (x = 0; x < im->xsize; x++) {
181181
i = (int) (((*in++)-fmin)*scale);
182-
if (i >= 0 && i < 256)
182+
if (i >= 0 && i < 256) {
183183
h->histogram[i]++;
184+
}
184185
}
185186
}
186187
ImagingSectionLeave(&cookie);

src/libImaging/Point.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ ImagingPointTransform(Imaging imIn, double scale, double offset)
219219

220220
if (!imIn || (strcmp(imIn->mode, "I") != 0 &&
221221
strcmp(imIn->mode, "I;16") != 0 &&
222-
strcmp(imIn->mode, "F") != 0))
222+
strcmp(imIn->mode, "F") != 0)) {
223223
return (Imaging) ImagingError_ModeError();
224+
}
224225

225226
imOut = ImagingNew(imIn->mode, imIn->xsize, imIn->ysize);
226227
if (!imOut) {

0 commit comments

Comments
 (0)