From 6afad7276402a90b3776ddeefb205978af42fdab Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 2 Aug 2017 23:25:13 +0200 Subject: Delete more assignments in if conditions. Based on below coccinelle script with a bad transformation fixed up manually. @if1@ expression E, F, G; binary operator X; statement S; @@ - if ((E = F) X G) + E = F; + if (E X G) S @if2@ expression E, F, G; binary operator X; statement S; @@ - if (G X (E = F)) + E = F; + if (E X G) S @if3@ expression E, F; statement S; @@ - if (!(E = F)) + E = F; + if (!E) S @if4@ expression E, F; statement S; @@ - if ((E = F)) + E = F; + if (E) S Signed-off-by: Ralf Baechle --- hdlcutil/smdiag.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'hdlcutil/smdiag.c') diff --git a/hdlcutil/smdiag.c b/hdlcutil/smdiag.c index 17ef026..14496c8 100644 --- a/hdlcutil/smdiag.c +++ b/hdlcutil/smdiag.c @@ -94,7 +94,8 @@ static int openwindow(char *disp, int constell, int samplesperbit) XColor color, dummy; XSizeHints sizehints; - if (!(display = XOpenDisplay(NULL))) + display = XOpenDisplay(NULL); + if (!display) return -1; XSetErrorHandler(x_error_handler); XAllocNamedColor(display, DefaultColormap(display, 0), "red", @@ -103,16 +104,17 @@ static int openwindow(char *disp, int constell, int samplesperbit) col_background = WhitePixel(display, 0); col_trace = BlackPixel(display, 0); attr.background_pixel = col_background; - if (!(window = XCreateWindow(display, XRootWindow(display, 0), - 200, 200, WIDTH, HEIGHT, 5, - DefaultDepth(display, 0), - InputOutput, DefaultVisual(display, 0), - CWBackPixel, &attr))) { + window = XCreateWindow(display, XRootWindow(display, 0), 200, 200, + WIDTH, HEIGHT, 5, DefaultDepth(display, 0), + InputOutput, DefaultVisual(display, 0), + CWBackPixel, &attr); + if (!window) { fprintf(stderr, "smdiag: unable to open X window\n"); exit(1); } - if (!(pixmap = XCreatePixmap(display, window, WIDTH, HEIGHT, - DefaultDepth(display, 0)))) { + pixmap = XCreatePixmap(display, window, WIDTH, HEIGHT, + DefaultDepth(display, 0)); + if (!pixmap) { fprintf(stderr, "smdiag: unable to open offscreen pixmap\n"); exit(1); } @@ -389,7 +391,8 @@ int main(int argc, char *argv[]) } else usleep(100000L); if (display) { - if ((cp = getkey())) { + cp = getkey(); + if (cp) { for (; *cp; cp++) { printf("char pressed: '%c'\n", *cp); switch (*cp) { -- cgit v1.2.3