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

Side by Side Diff: fusl/src/network/ether.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 unified diff | Download patch
OLDNEW
1 #include <stdlib.h> 1 #include <stdlib.h>
2 #include <netinet/ether.h> 2 #include <netinet/ether.h>
3 #include <stdio.h> 3 #include <stdio.h>
4 4
5 struct ether_addr *ether_aton_r (const char *x, struct ether_addr *p_a) 5 struct ether_addr* ether_aton_r(const char* x, struct ether_addr* p_a) {
6 { 6 struct ether_addr a;
7 » struct ether_addr a; 7 char* y;
8 » char *y; 8 for (int ii = 0; ii < 6; ii++) {
9 » for (int ii = 0; ii < 6; ii++) { 9 unsigned long int n;
10 » » unsigned long int n; 10 if (ii != 0) {
11 » » if (ii != 0) { 11 if (x[0] != ':')
12 » » » if (x[0] != ':') return 0; /* bad format */ 12 return 0; /* bad format */
13 » » » else x++; 13 else
14 » » } 14 x++;
15 » » n = strtoul (x, &y, 16); 15 }
16 » » x = y; 16 n = strtoul(x, &y, 16);
17 » » if (n > 0xFF) return 0; /* bad byte */ 17 x = y;
18 » » a.ether_addr_octet[ii] = n; 18 if (n > 0xFF)
19 » } 19 return 0; /* bad byte */
20 » if (x[0] != 0) return 0; /* bad format */ 20 a.ether_addr_octet[ii] = n;
21 » *p_a = a; 21 }
22 » return p_a; 22 if (x[0] != 0)
23 return 0; /* bad format */
24 *p_a = a;
25 return p_a;
23 } 26 }
24 27
25 struct ether_addr *ether_aton (const char *x) 28 struct ether_addr* ether_aton(const char* x) {
26 { 29 static struct ether_addr a;
27 » static struct ether_addr a; 30 return ether_aton_r(x, &a);
28 » return ether_aton_r (x, &a);
29 } 31 }
30 32
31 char *ether_ntoa_r (const struct ether_addr *p_a, char *x) { 33 char* ether_ntoa_r(const struct ether_addr* p_a, char* x) {
32 » char *y; 34 char* y;
33 » y = x; 35 y = x;
34 » for (int ii = 0; ii < 6; ii++) { 36 for (int ii = 0; ii < 6; ii++) {
35 » » x += sprintf (x, ii == 0 ? "%.2X" : ":%.2X", p_a->ether_addr_oct et[ii]); 37 x += sprintf(x, ii == 0 ? "%.2X" : ":%.2X", p_a->ether_addr_octet[ii]);
36 » } 38 }
37 » return y; 39 return y;
38 } 40 }
39 41
40 char *ether_ntoa (const struct ether_addr *p_a) { 42 char* ether_ntoa(const struct ether_addr* p_a) {
41 » static char x[18]; 43 static char x[18];
42 » return ether_ntoa_r (p_a, x); 44 return ether_ntoa_r(p_a, x);
43 } 45 }
44 46
45 int ether_line(const char *l, struct ether_addr *e, char *hostname) 47 int ether_line(const char* l, struct ether_addr* e, char* hostname) {
46 { 48 return -1;
47 » return -1;
48 } 49 }
49 50
50 int ether_ntohost(char *hostname, const struct ether_addr *e) 51 int ether_ntohost(char* hostname, const struct ether_addr* e) {
51 { 52 return -1;
52 » return -1;
53 } 53 }
54 54
55 int ether_hostton(const char *hostname, struct ether_addr *e) 55 int ether_hostton(const char* hostname, struct ether_addr* e) {
56 { 56 return -1;
57 » return -1;
58 } 57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698