Skip to content

Commit 367a55e

Browse files
author
Daniele Lacamera
committed
Aesthetic fixes. Code formatting.
1 parent 29ab066 commit 367a55e

File tree

11 files changed

+650
-583
lines changed

11 files changed

+650
-583
lines changed

include/heap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
type *newTop; \
1818
if (++heap->n >= heap->size) { \
1919
newTop = PICO_ZALLOC((heap->n + 1) * sizeof(type)); \
20-
if(!newTop) {\
21-
heap->n--;\
20+
if(!newTop) { \
21+
heap->n--; \
2222
return -1; \
2323
} \
2424
if (heap->top) { \

modules/pico_dev_ppp.c

Lines changed: 506 additions & 457 deletions
Large diffs are not rendered by default.

modules/pico_dhcp_client.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ static int recv_ack(struct pico_dhcp_client_cookie *dhcpc, uint8_t *buf)
536536
pico_ipv4_link_del(dhcpc->dev, l->address);
537537
l = pico_ipv4_link_by_dev_next(dhcpc->dev, l);
538538
}
539-
540539
pico_ipv4_link_add(dhcpc->dev, dhcpc->address, dhcpc->netmask);
541540

542541
dbg("DHCP client: renewal time (T1) %u\n", (unsigned int)dhcpc->t1_time);
@@ -884,7 +883,7 @@ static void pico_dhcp_client_wakeup(uint16_t ev, struct pico_socket *s)
884883
int r = 0;
885884
struct pico_dhcp_hdr *hdr = NULL;
886885
struct pico_dhcp_client_cookie *dhcpc = NULL;
887-
886+
888887
if (ev != PICO_SOCK_EV_RD)
889888
return;
890889

modules/pico_dns_client.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,17 @@ static int pico_dns_client_check_qsuffix(struct pico_dns_query_suffix *suf, stru
263263
dns_dbg("DNS ERROR: received qtype (%u) or qclass (%u) incorrect\n", short_be(suf->qtype), short_be(suf->qclass));
264264
return -1;
265265
}
266+
266267
return 0;
267268
}
268269

269270
static int pico_dns_client_check_url(struct pico_dns_header *resp, struct pico_dns_query *q)
270271
{
271272
char *recv_name = (char*)(resp) + sizeof(struct pico_dns_header) + PICO_DNS_LABEL_INITIAL;
272-
char *exp_name = (char *)(q->query) + sizeof(struct pico_dns_header) + PICO_DNS_LABEL_INITIAL;
273-
if (strcmp(recv_name, exp_name) != 0)
273+
char *exp_name = (char *)(q->query) + sizeof(struct pico_dns_header) + PICO_DNS_LABEL_INITIAL;
274+
if (strcmp(recv_name, exp_name) != 0)
274275
return -1;
276+
275277
return 0;
276278
}
277279

modules/pico_dns_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ int pico_dns_name_to_dns_notation(char *ptr, unsigned int maxlen)
7171
} else {
7272
len++;
7373
}
74+
7475
if ((unsigned int)(ptr - start) > maxlen)
7576
break;
7677
}

modules/pico_ipv4.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,7 @@ int pico_ipv4_link_add(struct pico_device *dev, struct pico_ip4 address, struct
15231523
dbg("Assigned ipv4 %s to device %s\n", ipstr, new->dev->name);
15241524
if (default_bcast_route.link == NULL)
15251525
default_bcast_route.link = new;
1526+
15261527
return 0;
15271528
}
15281529

@@ -1588,6 +1589,7 @@ int pico_ipv4_link_del(struct pico_device *dev, struct pico_ip4 address)
15881589
pico_tree_delete(&Tree_dev_link, found);
15891590
if (default_bcast_route.link == found)
15901591
default_bcast_route.link = NULL;
1592+
15911593
PICO_FREE(found);
15921594

15931595
return 0;

modules/pico_mdns.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ static void pico_mdns_wakeup(uint16_t ev, struct pico_socket *s)
894894
recvbuf = PICO_ZALLOC(PICO_MDNS_MAXBUF);
895895
if (!recvbuf)
896896
return;
897+
897898
mdns_dbg("READ EVENT!\n");
898899
/* receive while data available in socket buffer */
899900
while((pico_read = pico_socket_recvfrom(s, recvbuf, PICO_MDNS_MAXBUF, &peer, &port)) > 0) {

modules/pico_sntp_client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ static void pico_sntp_client_wakeup(uint16_t ev, struct pico_socket *s)
166166
recvbuf = PICO_ZALLOC(PICO_SNTP_MAXBUF);
167167
if (!recvbuf)
168168
return;
169+
169170
do {
170171
read = pico_socket_recvfrom(s, recvbuf, PICO_SNTP_MAXBUF, &peer, &port);
171172
} while(read > 0);
@@ -354,6 +355,7 @@ int pico_sntp_sync(const char *sntp_server, void (*cb_synced)(pico_err_t status)
354355
PICO_FREE(ck);
355356
return -1;
356357
}
358+
357359
return 0;
358360
}
359361

stack/pico_frame.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ void pico_frame_discard(struct pico_frame *f)
2525
if (*f->usage_count <= 0) {
2626
if (f->flags & PICO_FRAME_FLAG_EXT_USAGE_COUNTER)
2727
PICO_FREE(f->usage_count);
28+
2829
#ifdef PICO_SUPPORT_DEBUG_MEMORY
2930
dbg("Discarded buffer @%p, caller: %p\n", f->buffer, __builtin_return_address(3));
3031
dbg("DEBUG MEMORY: %d frames in use.\n", --n_frames_allocated);
@@ -81,11 +82,13 @@ static struct pico_frame *pico_frame_do_alloc(uint32_t size, int zerocopy, int e
8182
if (align) {
8283
frame_buffer_size += (uint32_t)sizeof(uint32_t) - align;
8384
}
85+
8486
p->buffer = PICO_ZALLOC(frame_buffer_size + sizeof(uint32_t));
8587
if (!p->buffer) {
8688
PICO_FREE(p);
8789
return NULL;
8890
}
91+
8992
p->usage_count = (uint32_t *)(((uint8_t*)p->buffer) + size);
9093
} else {
9194
p->buffer = NULL;

test/ppp.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,30 @@
1414
#endif
1515
#define MODEM "/dev/ttyUSB1"
1616
#define SPEED 236800
17-
//#define APN "gprs.base.be"
17+
/* #define APN "gprs.base.be" */
1818
#define APN "web.be"
1919
#define PASSWD "web"
20-
//#define DEBUG_FLOW
20+
/* #define DEBUG_FLOW */
2121
static int fd = -1;
2222
static int idx;
2323
static int ping_on = 0;
2424
static struct pico_device *ppp = NULL;
2525

2626
static void sigusr1_hdl(int signo)
2727
{
28-
fprintf(stderr, "SIGUSR1: Connecting!\n");
29-
if (ppp)
30-
pico_ppp_connect(ppp);
28+
fprintf(stderr, "SIGUSR1: Connecting!\n");
29+
if (ppp)
30+
pico_ppp_connect(ppp);
3131
}
3232

3333
static void sigusr2_hdl(int signo)
3434
{
35-
fprintf(stderr, "SIGUSR2/SIGINT: Disconnecting!\n");
36-
if (ppp)
37-
pico_ppp_disconnect(ppp);
38-
if (signo == SIGINT)
39-
exit(0);
35+
fprintf(stderr, "SIGUSR2/SIGINT: Disconnecting!\n");
36+
if (ppp)
37+
pico_ppp_disconnect(ppp);
38+
39+
if (signo == SIGINT)
40+
exit(0);
4041
}
4142

4243
#ifdef PICO_SUPPORT_POLARSSL
@@ -68,6 +69,7 @@ int modem_read(struct pico_device *dev, void *data, int len)
6869
}
6970
printf("\n");
7071
}
72+
7173
#endif
7274

7375
return r;
@@ -92,10 +94,13 @@ int modem_set_speed(struct pico_device *dev, uint32_t speed)
9294
struct termios term;
9395
if (tcgetattr(fd, &term) != 0)
9496
return 6;
97+
9598
if (cfsetspeed(&term, B115200) != 0)
9699
return 7;
100+
97101
if (tcsetattr(fd, TCSANOW, &term) != 0)
98102
return 8;
103+
99104
printf("Speed set to 115200.\n");
100105
return 0;
101106
}
@@ -116,7 +121,7 @@ static void cb_sock(uint16_t ev, struct pico_socket *s)
116121

117122
}
118123

119-
static void ping(void)
124+
static void ping(void)
120125
{
121126
struct pico_socket *s;
122127
struct pico_ip4 dst;
@@ -136,8 +141,10 @@ int main(int argc, const char *argv[])
136141

137142
if (argc > 1)
138143
path = argv[1];
144+
139145
if (argc > 2)
140146
apn = argv[2];
147+
141148
if (argc > 3)
142149
passwd = argv[3];
143150

@@ -157,7 +164,7 @@ int main(int argc, const char *argv[])
157164

158165
ppp = pico_ppp_create();
159166
if (!ppp)
160-
return 2;
167+
return 2;
161168

162169
pico_ppp_set_serial_read(ppp, modem_read);
163170
pico_ppp_set_serial_write(ppp, modem_write);
@@ -176,5 +183,4 @@ int main(int argc, const char *argv[])
176183
ping();
177184
}
178185
}
179-
180186
}

0 commit comments

Comments
 (0)