Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1067)

Unified Diff: fusl/src/network/getservbyport_r.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: fusl/src/network/getservbyport_r.c
diff --git a/fusl/src/network/getservbyport_r.c b/fusl/src/network/getservbyport_r.c
index a0a7caecf77e8dd89bbbc3aa3ee3d3b4112ac08a..bc0b548d0b25a9d5a55202b5177516db2f8d4265 100644
--- a/fusl/src/network/getservbyport_r.c
+++ b/fusl/src/network/getservbyport_r.c
@@ -6,50 +6,55 @@
#include <errno.h>
#include <string.h>
-int getservbyport_r(int port, const char *prots,
- struct servent *se, char *buf, size_t buflen, struct servent **res)
-{
- int i;
- struct sockaddr_in sin = {
- .sin_family = AF_INET,
- .sin_port = port,
- };
+int getservbyport_r(int port,
+ const char* prots,
+ struct servent* se,
+ char* buf,
+ size_t buflen,
+ struct servent** res) {
+ int i;
+ struct sockaddr_in sin = {
+ .sin_family = AF_INET, .sin_port = port,
+ };
- if (!prots) {
- int r = getservbyport_r(port, "tcp", se, buf, buflen, res);
- if (r) r = getservbyport_r(port, "udp", se, buf, buflen, res);
- return r;
- }
+ if (!prots) {
+ int r = getservbyport_r(port, "tcp", se, buf, buflen, res);
+ if (r)
+ r = getservbyport_r(port, "udp", se, buf, buflen, res);
+ return r;
+ }
- /* Align buffer */
- i = (uintptr_t)buf & sizeof(char *)-1;
- if (!i) i = sizeof(char *);
- if (buflen < 3*sizeof(char *)-i)
- return ERANGE;
- buf += sizeof(char *)-i;
- buflen -= sizeof(char *)-i;
+ /* Align buffer */
+ i = (uintptr_t)buf & sizeof(char*) - 1;
+ if (!i)
+ i = sizeof(char*);
+ if (buflen < 3 * sizeof(char*) - i)
+ return ERANGE;
+ buf += sizeof(char*) - i;
+ buflen -= sizeof(char*) - i;
- if (strcmp(prots, "tcp") && strcmp(prots, "udp")) return EINVAL;
+ if (strcmp(prots, "tcp") && strcmp(prots, "udp"))
+ return EINVAL;
- se->s_port = port;
- se->s_proto = (char *)prots;
- se->s_aliases = (void *)buf;
- buf += 2*sizeof(char *);
- buflen -= 2*sizeof(char *);
- se->s_aliases[1] = 0;
- se->s_aliases[0] = se->s_name = buf;
+ se->s_port = port;
+ se->s_proto = (char*)prots;
+ se->s_aliases = (void*)buf;
+ buf += 2 * sizeof(char*);
+ buflen -= 2 * sizeof(char*);
+ se->s_aliases[1] = 0;
+ se->s_aliases[0] = se->s_name = buf;
- switch (getnameinfo((void *)&sin, sizeof sin, 0, 0, buf, buflen,
- strcmp(prots, "udp") ? 0 : NI_DGRAM)) {
- case EAI_MEMORY:
- case EAI_SYSTEM:
- return ENOMEM;
- default:
- return ENOENT;
- case 0:
- break;
- }
+ switch (getnameinfo((void*)&sin, sizeof sin, 0, 0, buf, buflen,
+ strcmp(prots, "udp") ? 0 : NI_DGRAM)) {
+ case EAI_MEMORY:
+ case EAI_SYSTEM:
+ return ENOMEM;
+ default:
+ return ENOENT;
+ case 0:
+ break;
+ }
- *res = se;
- return 0;
+ *res = se;
+ return 0;
}

Powered by Google App Engine
This is Rietveld 408576698