From 5f4379bfe7fcd17216160e945b66d72002b2b0b2 Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Sat, 17 Jan 2015 23:58:43 +0100 Subject: sds.c: All if statements should be braced --- src/sds.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/sds.c b/src/sds.c index aa326a2..6573634 100644 --- a/src/sds.c +++ b/src/sds.c @@ -56,8 +56,9 @@ sds sdsnewlen(const void *init, size_t initlen) { if (sh == NULL) return NULL; sh->len = initlen; sh->free = 0; - if (initlen && init) + if (initlen && init) { memcpy(sh->buf, init, initlen); + } sh->buf[initlen] = '\0'; return (char*)sh->buf; } @@ -132,10 +133,11 @@ sds sdsMakeRoomFor(sds s, size_t addlen) { len = sdslen(s); sh = sdsheader(s); newlen = (len+addlen); - if (newlen < SDS_MAX_PREALLOC) + if (newlen < SDS_MAX_PREALLOC) { newlen *= 2; - else + } else { newlen += SDS_MAX_PREALLOC; + } newsh = realloc(sh, sizeof(struct sdshdr)+newlen+1); if (newsh == NULL) return NULL; @@ -560,11 +562,12 @@ sds sdscatrepr(sds s, const char *p, size_t len) { case '\a': s = sdscatlen(s,"\\a",2); break; case '\b': s = sdscatlen(s,"\\b",2); break; default: - if (isprint(*p)) + if (isprint(*p)) { s = sdscatprintf(s,"%c",*p); - else + } else { s = sdscatprintf(s,"\\x%02x",(unsigned char)*p); break; + } } p++; } -- cgit v1.2.3-70-g09d2