- Add `void` as parameter for functions which do not take any Arguments
- Use a block if the body of a loop consists of an `if` statement
- A few changes such as moving a curley bracket

---
diff --git a/drw.c b/drw.c
index c1582e746cc5..84f87b972384 100644
--- a/drw.c
+++ b/drw.c
@@ -19,9 +19,10 @@ static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 
0x7FF, 0xFFFF, 0x10FFFF
 static long
 utf8decodebyte(const char c, size_t *i)
 {
-       for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
+       for (*i = 0; *i < (UTF_SIZ + 1); ++(*i)) {
                if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
                        return (unsigned char)c & ~utfmask[*i];
+       }
        return 0;
 }
 
diff --git a/sent.c b/sent.c
index 9534fcaf97b9..a27b704cd5ce 100644
--- a/sent.c
+++ b/sent.c
@@ -99,12 +99,12 @@ static void load(FILE *fp);
 static void advance(const Arg *arg);
 static void quit(const Arg *arg);
 static void resize(int width, int height);
-static void run();
-static void usage();
-static void xdraw();
-static void xhints();
-static void xinit();
-static void xloadfonts();
+static void run(void);
+static void usage(void);
+static void xdraw(void);
+static void xhints(void);
+static void xinit(void);
+static void xloadfonts(void);
 
 static void bpress(XEvent *);
 static void cmessage(XEvent *);
@@ -116,12 +116,12 @@ static void configure(XEvent *);
 #include "config.h"
 
 /* Globals */
-static const char *fname = NULL;
-static Slide *slides = NULL;
-static int idx = 0;
-static int slidecount = 0;
+static const char *fname;
+static Slide *slides;
+static int idx;
+static int slidecount;
 static XWindow xw;
-static Drw *d = NULL;
+static Drw *d;
 static Clr *sc;
 static Fnt *fonts[NUMFONTSCALES];
 static int running = 1;
@@ -326,9 +326,10 @@ getfontsize(Slide *s, unsigned int *width, unsigned int 
*height)
        float lfac = linespacing * (s->linecount - 1) + 1;
 
        /* fit height */
-       for (j = NUMFONTSCALES - 1; j >= 0; j--)
+       for (j = NUMFONTSCALES - 1; j >= 0; j--) {
                if (fonts[j]->h * lfac <= xw.uh)
                        break;
+       }
        LIMIT(j, 0, NUMFONTSCALES - 1);
        drw_setfontset(d, fonts[j]);
 
@@ -381,7 +382,7 @@ cleanup(int slidesonly)
 void
 reload(const Arg *arg)
 {
-       FILE *fp = NULL;
+       FILE *fp;
        unsigned int i;
 
        if (!fname) {
@@ -414,15 +415,17 @@ load(FILE *fp)
        /* read each line from fp and add it to the item list */
        while (1) {
                /* eat consecutive empty lines */
-               while ((p = fgets(buf, sizeof(buf), fp)))
+               while ((p = fgets(buf, sizeof(buf), fp))) {
                        if (strcmp(buf, "\n") != 0 && buf[0] != '#')
                                break;
+               }
                if (!p)
                        break;
 
-               if ((slidecount+1) * sizeof(*slides) >= size)
+               if ((slidecount+1) * sizeof(*slides) >= size) {
                        if (!(slides = realloc(slides, (size += BUFSIZ))))
                                die("sent: Unable to reallocate %u bytes:", 
size);
+               }
 
                /* read one slide */
                maxlines = 0;
@@ -496,7 +499,7 @@ resize(int width, int height)
 }
 
 void
-run()
+run(void)
 {
        XEvent ev;
 
@@ -518,7 +521,7 @@ run()
 }
 
 void
-xdraw()
+xdraw(void)
 {
        unsigned int height, width, i;
        Image *im = slides[idx].img;
@@ -528,15 +531,11 @@ xdraw()
 
        if (!im) {
                drw_rect(d, 0, 0, xw.w, xw.h, 1, 1);
-               for (i = 0; i < slides[idx].linecount; i++)
-                       drw_text(d,
-                                (xw.w - width) / 2,
+               for (i = 0; i < slides[idx].linecount; i++) {
+                       drw_text(d, (xw.w - width) / 2,
                                 (xw.h - height) / 2 + i * linespacing * 
d->fonts->h,
-                                width,
-                                d->fonts->h,
-                                0,
-                                slides[idx].lines[i],
-                                0);
+                                width, d->fonts->h, 0, slides[idx].lines[i], 
0);
+               }
                drw_map(d, xw.win, 0, 0, xw.w, xw.h);
        } else {
                if (!(im->state & SCALED))
@@ -546,7 +545,7 @@ xdraw()
 }
 
 void
-xhints()
+xhints(void)
 {
        XClassHint class = {.res_name = "sent", .res_class = "presenter"};
        XWMHints wm = {.flags = InputHint, .input = True};
@@ -564,7 +563,7 @@ xhints()
 }
 
 void
-xinit()
+xinit(void)
 {
        XTextProperty prop;
        unsigned int i;
@@ -608,14 +607,13 @@ xinit()
 }
 
 void
-xloadfonts()
+xloadfonts(void)
 {
        int i, j;
        char *fstrs[LEN(fontfallbacks)];
 
-       for (j = 0; j < LEN(fontfallbacks); j++) {
+       for (j = 0; j < LEN(fontfallbacks); j++)
                fstrs[j] = ecalloc(1, MAXFONTSTRLEN);
-       }
 
        for (i = 0; i < NUMFONTSCALES; i++) {
                for (j = 0; j < LEN(fontfallbacks); j++) {
@@ -626,9 +624,10 @@ xloadfonts()
                        die("sent: Unable to load any font for size %d", 
FONTSZ(i));
        }
 
-       for (j = 0; j < LEN(fontfallbacks); j++)
+       for (j = 0; j < LEN(fontfallbacks); j++) {
                if (fstrs[j])
                        free(fstrs[j]);
+       }
 }
 
 void
@@ -636,9 +635,10 @@ bpress(XEvent *e)
 {
        unsigned int i;
 
-       for (i = 0; i < LEN(mshortcuts); i++)
+       for (i = 0; i < LEN(mshortcuts); i++) {
                if (e->xbutton.button == mshortcuts[i].b && mshortcuts[i].func)
                        mshortcuts[i].func(&(mshortcuts[i].arg));
+       }
 }
 
 void
@@ -662,9 +662,10 @@ kpress(XEvent *e)
        KeySym sym;
 
        sym = XkbKeycodeToKeysym(xw.dpy, (KeyCode)e->xkey.keycode, 0, 0);
-       for (i = 0; i < LEN(shortcuts); i++)
+       for (i = 0; i < LEN(shortcuts); i++) {
                if (sym == shortcuts[i].keysym && shortcuts[i].func)
                        shortcuts[i].func(&(shortcuts[i].arg));
+       }
 }
 
 void
@@ -677,7 +678,7 @@ configure(XEvent *e)
 }
 
 void
-usage()
+usage(void)
 {
        die("usage: %s [file]", argv0);
 }
diff --git a/util.c b/util.c
index fe044fc7b797..176f80762cd8 100644
--- a/util.c
+++ b/util.c
@@ -17,7 +17,8 @@ ecalloc(size_t nmemb, size_t size)
 }
 
 void
-die(const char *fmt, ...) {
+die(const char *fmt, ...)
+{
        va_list ap;
 
        va_start(ap, fmt);
--


Reply via email to