PPPD: Fix a few coding style problems

This commit is contained in:
Gregory Nutt 2015-09-01 17:28:17 -06:00
parent 1f7a8d2f8d
commit ae0d87c0cb
3 changed files with 41 additions and 36 deletions

View File

@ -365,12 +365,12 @@ u8_t ahdlc_tx(struct ppp_context_s *ctx, u16_t protocol, u8_t *header,
#if PACKET_TX_DEBUG #if PACKET_TX_DEBUG
DEBUG1(("\n")); DEBUG1(("\n"));
for(i = 0; i < headerlen; ++i) for (i = 0; i < headerlen; ++i)
{ {
DEBUG1(("0x%02x ", header[i])); DEBUG1(("0x%02x ", header[i]));
} }
for(i = 0; i < datalen; ++i) for (i = 0; i < datalen; ++i)
{ {
DEBUG1(("0x%02x ", buffer[i])); DEBUG1(("0x%02x ", buffer[i]));
} }
@ -405,7 +405,7 @@ u8_t ahdlc_tx(struct ppp_context_s *ctx, u16_t protocol, u8_t *header,
/* Write header if it exists */ /* Write header if it exists */
for(i = 0; i < headerlen; ++i) for (i = 0; i < headerlen; ++i)
{ {
/* Get next byte from buffer */ /* Get next byte from buffer */
@ -418,7 +418,7 @@ u8_t ahdlc_tx(struct ppp_context_s *ctx, u16_t protocol, u8_t *header,
/* Write frame bytes */ /* Write frame bytes */
for(i = 0; i < datalen; ++i) for (i = 0; i < datalen; ++i)
{ {
/* Get next byte from buffer */ /* Get next byte from buffer */

View File

@ -99,7 +99,7 @@ static void ppp_reject_protocol(struct ppp_context_s *ctx, u16_t protocol,
dptr = buffer + count + 6; dptr = buffer + count + 6;
sptr = buffer + count; sptr = buffer + count;
for(i = 0; i < count; ++i) for (i = 0; i < count; ++i)
{ {
*dptr-- = *sptr--; *dptr-- = *sptr--;
} }
@ -127,7 +127,7 @@ void dump_ppp_packet(u8_t *buffer, u16_t len)
int i; int i;
DEBUG1(("\n")); DEBUG1(("\n"));
for(i = 0;i < len; ++i) for (i = 0;i < len; ++i)
{ {
if ((i & 0x1f) == 0x10) if ((i & 0x1f) == 0x10)
{ {
@ -371,41 +371,42 @@ void ppp_upcall(struct ppp_context_s *ctx, u16_t protocol, u8_t *buffer, u16_t l
{ {
/* Demux on protocol field */ /* Demux on protocol field */
switch(protocol) { switch (protocol)
case LCP: /* We must support some level of LCP */ {
DEBUG1(("LCP Packet - ")); case LCP: /* We must support some level of LCP */
lcp_rx(ctx, buffer, len); DEBUG1(("LCP Packet - "));
DEBUG1(("\n")); lcp_rx(ctx, buffer, len);
break; DEBUG1(("\n"));
break;
#ifdef CONFIG_NETUTILS_PPPD_PAP #ifdef CONFIG_NETUTILS_PPPD_PAP
case PAP: /* PAP should be compile in optional */ case PAP: /* PAP should be compile in optional */
DEBUG1(("PAP Packet - ")); DEBUG1(("PAP Packet - "));
pap_rx(ctx, buffer, len); pap_rx(ctx, buffer, len);
DEBUG1(("\n")); DEBUG1(("\n"));
break; break;
#endif /* CONFIG_NETUTILS_PPPD_PAP */ #endif /* CONFIG_NETUTILS_PPPD_PAP */
case IPCP: /* IPCP should be compile in optional. */ case IPCP: /* IPCP should be compile in optional. */
DEBUG1(("IPCP Packet - ")); DEBUG1(("IPCP Packet - "));
ipcp_rx(ctx, buffer, len); ipcp_rx(ctx, buffer, len);
DEBUG1(("\n")); DEBUG1(("\n"));
break; break;
case IPV4: /* We must support IPV4 */ case IPV4: /* We must support IPV4 */
DEBUG1(("IPV4 Packet---\n")); DEBUG1(("IPV4 Packet---\n"));
memcpy(ctx->ip_buf, buffer, len); memcpy(ctx->ip_buf, buffer, len);
ctx->ip_len = len; ctx->ip_len = len;
ctx->ip_no_data_time = 0; ctx->ip_no_data_time = 0;
DEBUG1(("\n")); DEBUG1(("\n"));
break; break;
default: default:
DEBUG1(("Unknown PPP Packet Type 0x%04x - ",protocol)); DEBUG1(("Unknown PPP Packet Type 0x%04x - ",protocol));
ppp_reject_protocol(ctx, protocol, buffer, len); ppp_reject_protocol(ctx, protocol, buffer, len);
DEBUG1(("\n")); DEBUG1(("\n"));
break; break;
} }
} }
} }
@ -460,7 +461,7 @@ u16_t scan_packet(struct ppp_context_s *ctx, u16_t protocol, const u8_t *list,
bad = 1; bad = 1;
*tptr++ = i; *tptr++ = i;
j = *tptr++ = *bptr++; j = *tptr++ = *bptr++;
for(i = 0; i < j - 2; ++i) for (i = 0; i < j - 2; ++i)
{ {
*tptr++ = *bptr++; *tptr++ = *bptr++;
} }

View File

@ -113,7 +113,9 @@ static int tun_alloc(char *dev)
int fd, err; int fd, err;
if ((fd = open("/dev/tun", O_RDWR)) < 0) if ((fd = open("/dev/tun", O_RDWR)) < 0)
{
return fd; return fd;
}
printf("tun fd:%i\n", fd); printf("tun fd:%i\n", fd);
@ -151,7 +153,9 @@ static int open_tty(char *dev)
int err; int err;
if ((fd = open(dev, O_RDWR)) < 0) if ((fd = open(dev, O_RDWR)) < 0)
{
return fd; return fd;
}
if ((err = make_nonblock(fd)) < 0) if ((err = make_nonblock(fd)) < 0)
{ {