diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-01-12 12:33:30 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-01-12 12:33:30 +0000 |
commit | 0233bdfa2b487c392dc4fd1a29113e08fbace334 (patch) | |
tree | 83551e09979e7baa762cd11a65ddff2153883e4e /src/if_xcmdsrv.c | |
parent | 043d7b2c84cda275354aa023b5769660ea70a168 (diff) |
patch 9.0.1183: code is indented more than necessaryv9.0.1183
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11805)
Diffstat (limited to 'src/if_xcmdsrv.c')
-rw-r--r-- | src/if_xcmdsrv.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/src/if_xcmdsrv.c b/src/if_xcmdsrv.c index 1aa09fd4a3..d9408398d9 100644 --- a/src/if_xcmdsrv.c +++ b/src/if_xcmdsrv.c @@ -221,31 +221,32 @@ serverRegisterName( char_u *p = NULL; res = DoRegisterName(dpy, name); - if (res < 0) + if (res >= 0) + return OK; + + i = 1; + do { - i = 1; - do + if (res < -1 || i >= 1000) { - if (res < -1 || i >= 1000) - { - msg_attr(_("Unable to register a command server name"), - HL_ATTR(HLF_W)); - return FAIL; - } - if (p == NULL) - p = alloc(STRLEN(name) + 10); - if (p == NULL) - { - res = -10; - continue; - } - sprintf((char *)p, "%s%d", name, i++); - res = DoRegisterName(dpy, p); + msg_attr(_("Unable to register a command server name"), + HL_ATTR(HLF_W)); + return FAIL; } - while (res < 0) - ; - vim_free(p); + if (p == NULL) + p = alloc(STRLEN(name) + 10); + if (p == NULL) + { + res = -10; + continue; + } + sprintf((char *)p, "%s%d", name, i++); + res = DoRegisterName(dpy, p); } + while (res < 0) + ; + vim_free(p); + return OK; } @@ -756,17 +757,17 @@ serverSendReply(char_u *name, char_u *str) return -1; length = STRLEN(p_enc) + STRLEN(str) + 14; - if ((property = alloc(length + 30)) != NULL) - { - sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x", - 0, 0, p_enc, 0, str, 0, (unsigned int)commWindow); - // Add length of what "%x" resulted in. - length += STRLEN(property + length); - res = AppendPropCarefully(dpy, win, commProperty, property, length + 1); - vim_free(property); - return res; - } - return -1; + if ((property = alloc(length + 30)) == NULL) + return -1; + + sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x", + 0, 0, p_enc, 0, str, 0, (unsigned int)commWindow); + // Add length of what "%x" resulted in. + length += STRLEN(property + length); + res = AppendPropCarefully(dpy, win, commProperty, property, length + 1); + vim_free(property); + + return res; } static int |