Commit 4fd77487 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Aurelio Colosimo

arch-* and toplevel: checkpatch changes

These remove style warnings and errors, mostly mine. External files
(such as hw files in arch-spec and syscall stuff in bare-linux) have
not been fixed and should not be, in my opinion.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 277d5cef
...@@ -12,11 +12,12 @@ void pp_puts(const char *s) ...@@ -12,11 +12,12 @@ void pp_puts(const char *s)
int pp_strnlen(const char *s, int maxlen) int pp_strnlen(const char *s, int maxlen)
{ {
int len = 0; int len = 0;
while (*(s++)) len++; while (*(s++))
len++;
return len; return len;
} }
void *pp_memcpy(void * dest, const void *src, int count) void *pp_memcpy(void *dest, const void *src, int count)
{ {
/* from u-boot-1.1.2 */ /* from u-boot-1.1.2 */
char *tmp = (char *) dest, *s = (char *) src; char *tmp = (char *) dest, *s = (char *) src;
......
...@@ -30,7 +30,6 @@ extern int sys_bind(int fd, const struct bare_sockaddr *addr, int addrlen); ...@@ -30,7 +30,6 @@ extern int sys_bind(int fd, const struct bare_sockaddr *addr, int addrlen);
extern int sys_recv(int fd, void *pkt, int plen, int flags); extern int sys_recv(int fd, void *pkt, int plen, int flags);
extern int sys_send(int fd, void *pkt, int plen, int flags); extern int sys_send(int fd, void *pkt, int plen, int flags);
extern int bare_errno; extern int bare_errno;
/* structures passed to syscalls */ /* structures passed to syscalls */
...@@ -42,8 +41,7 @@ struct bare_sockaddr { ...@@ -42,8 +41,7 @@ struct bare_sockaddr {
}; };
struct bare_ifreq { struct bare_ifreq {
union union {
{
char ifrn_name[IFNAMSIZ]; char ifrn_name[IFNAMSIZ];
} ifr_ifrn; } ifr_ifrn;
...@@ -68,7 +66,7 @@ struct bare_sockaddr_ll { ...@@ -68,7 +66,7 @@ struct bare_sockaddr_ll {
/* other network stuff, bah.... */ /* other network stuff, bah.... */
struct bare_ethhdr { struct bare_ethhdr {
unsigned char h_dest[6]; unsigned char h_dest[6];
unsigned char h_source[6]; unsigned char h_source[6];
uint16_t h_proto; uint16_t h_proto;
} __attribute__((packed)); } __attribute__((packed));
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
#include <pptp/diag.h> #include <pptp/diag.h>
#include "bare-linux.h" #include "bare-linux.h"
extern int __bss_start, __bss_end;
void pptp_clear_bss(void) void pptp_clear_bss(void)
{ {
int *ptr; int *ptr;
extern int __bss_start, __bss_end;
for (ptr = &__bss_start; ptr < &__bss_end; ptr++) for (ptr = &__bss_start; ptr < &__bss_end; ptr++)
*ptr = 0; *ptr = 0;
...@@ -34,7 +34,7 @@ void pptp_main(void) ...@@ -34,7 +34,7 @@ void pptp_main(void)
pp_diag_error(ppi, bare_errno); pp_diag_error(ppi, bare_errno);
pp_diag_fatal(ppi, "open_ch", ""); pp_diag_fatal(ppi, "open_ch", "");
} }
pp_open_instance(ppi,0); pp_open_instance(ppi, 0);
bare_main_loop(ppi); bare_main_loop(ppi);
} }
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
/* Architecture-specific defines, included by top-level stuff */ /* Architecture-specific defines, included by top-level stuff */
/* please note that these have multiple evaluation of the argument */ /* please note that these have multiple evaluation of the argument */
#define htons(x) __bswap_16(x) #define htons(x) __bswap_16(x)
#define __bswap_16(x) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) #define __bswap_16(x) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
#define htonl(x) __bswap_32(x) #define htonl(x) __bswap_32(x)
#define __bswap_32(x) ( \ #define __bswap_32(x) ( \
(((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \ (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
(((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \ (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
(((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \ (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
(((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)) (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24))
#define ntohs htons #define ntohs htons
#define ntohl htonl #define ntohl htonl
......
...@@ -10,11 +10,17 @@ ...@@ -10,11 +10,17 @@
#include "bare-linux.h" #include "bare-linux.h"
/* Define other hackish stuff */ /* Define other hackish stuff */
typedef struct {unsigned long bits[1024/32];} bare_fd_set; struct bare_fd_set {
#define FD_ZERO(p) memset(p, 0, sizeof(p)) unsigned long bits[1024/32];
#define FD_SET(bit, p) ((p)->bits[0] |= (1 << (bit))) };
struct bare_timeval {unsigned long tv_sec; unsigned long tv_usec;}; #define FD_ZERO(p) memset(p, 0, sizeof(p))
#define FD_SET(bit, p) ((p)->bits[0] |= (1 << (bit)))
struct bare_timeval {
unsigned long tv_sec;
unsigned long tv_usec;
};
#define NULL 0 #define NULL 0
...@@ -29,7 +35,7 @@ void bare_main_loop(struct pp_instance *ppi) ...@@ -29,7 +35,7 @@ void bare_main_loop(struct pp_instance *ppi)
*/ */
delay_ms = pp_state_machine(ppi, NULL, 0); delay_ms = pp_state_machine(ppi, NULL, 0);
while (1) { while (1) {
bare_fd_set set; struct bare_fd_set set;
int i, maxfd; int i, maxfd;
struct bare_timeval tv; struct bare_timeval tv;
unsigned char packet[1500]; unsigned char packet[1500];
...@@ -65,7 +71,7 @@ void bare_main_loop(struct pp_instance *ppi) ...@@ -65,7 +71,7 @@ void bare_main_loop(struct pp_instance *ppi)
*/ */
i = bare_recv_packet(ppi, packet, sizeof(packet)); i = bare_recv_packet(ppi, packet, sizeof(packet));
/* FIXME: PP_PROTO_NR is a legacy number */ /* FIXME: PP_PROTO_NR is a legacy number */
if ( ((struct bare_ethhdr *)packet)->h_proto if (((struct bare_ethhdr *)packet)->h_proto
!= htons(PP_PROTO_NR)) != htons(PP_PROTO_NR))
goto again; goto again;
......
/* /*
* Alessandro Rubini for CERN, 2011 -- public domain * Alessandro Rubini for CERN, 2011 -- public domain
*/ */
#include <asm/unistd.h> #include <linux/unistd.h>
#include <pptp/pptp.h> #include <pptp/pptp.h>
#include "bare-linux.h" #include "bare-linux.h"
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
int bare_errno; int bare_errno;
struct sel_arg_struct { struct sel_arg_struct {
unsigned long n; unsigned long n;
void *inp, *outp, *exp; void *inp, *outp, *exp;
void *tvp; void *tvp;
}; };
/* /*
...@@ -49,24 +49,24 @@ int sys_select(int max, void *in, void *out, void *exc, void *tout) ...@@ -49,24 +49,24 @@ int sys_select(int max, void *in, void *out, void *exc, void *tout)
} }
/* i386 has the socketcall thing. Bah! */ /* i386 has the socketcall thing. Bah! */
#define SYS_SOCKET 1 /* sys_socket(2) */ #define SYS_SOCKET 1 /* sys_socket(2) */
#define SYS_BIND 2 /* sys_bind(2) */ #define SYS_BIND 2 /* sys_bind(2) */
#define SYS_CONNECT 3 /* sys_connect(2) */ #define SYS_CONNECT 3 /* sys_connect(2) */
#define SYS_LISTEN 4 /* sys_listen(2) */ #define SYS_LISTEN 4 /* sys_listen(2) */
#define SYS_ACCEPT 5 /* sys_accept(2) */ #define SYS_ACCEPT 5 /* sys_accept(2) */
#define SYS_GETSOCKNAME 6 /* sys_getsockname(2) */ #define SYS_GETSOCKNAME 6 /* sys_getsockname(2) */
#define SYS_GETPEERNAME 7 /* sys_getpeername(2) */ #define SYS_GETPEERNAME 7 /* sys_getpeername(2) */
#define SYS_SOCKETPAIR 8 /* sys_socketpair(2) */ #define SYS_SOCKETPAIR 8 /* sys_socketpair(2) */
#define SYS_SEND 9 /* sys_send(2) */ #define SYS_SEND 9 /* sys_send(2) */
#define SYS_RECV 10 /* sys_recv(2) */ #define SYS_RECV 10 /* sys_recv(2) */
#define SYS_SENDTO 11 /* sys_sendto(2) */ #define SYS_SENDTO 11 /* sys_sendto(2) */
#define SYS_RECVFROM 12 /* sys_recvfrom(2) */ #define SYS_RECVFROM 12 /* sys_recvfrom(2) */
#define SYS_SHUTDOWN 13 /* sys_shutdown(2) */ #define SYS_SHUTDOWN 13 /* sys_shutdown(2) */
#define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */ #define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */
#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */ #define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
#define SYS_SENDMSG 16 /* sys_sendmsg(2) */ #define SYS_SENDMSG 16 /* sys_sendmsg(2) */
#define SYS_RECVMSG 17 /* sys_recvmsg(2) */ #define SYS_RECVMSG 17 /* sys_recvmsg(2) */
#define SYS_PACCEPT 18 /* sys_paccept(2) */ #define SYS_PACCEPT 18 /* sys_paccept(2) */
static unsigned long args[4]; static unsigned long args[4];
...@@ -74,7 +74,7 @@ int sys_socket(int domain, int type, int proto) ...@@ -74,7 +74,7 @@ int sys_socket(int domain, int type, int proto)
{ {
/* /*
* Strangely, this is not working for me: * Strangely, this is not working for me:
* unsigned long args[3] = {domain, type, proto}; * unsigned long args[3] = {domain, type, proto};
* So let's use an external thing. Who knows why... * So let's use an external thing. Who knows why...
*/ */
args[0] = domain; args[0] = domain;
......
...@@ -52,7 +52,7 @@ void posix_main_loop(struct pp_instance *ppi) ...@@ -52,7 +52,7 @@ void posix_main_loop(struct pp_instance *ppi)
} }
/* Warning: PP_PROTO_NR is endian-agnostic by design */ /* Warning: PP_PROTO_NR is endian-agnostic by design */
if ( ((struct ethhdr *)packet)->h_proto != htons(PP_PROTO_NR)) { if (((struct ethhdr *)packet)->h_proto != htons(PP_PROTO_NR)) {
delay_ms = -1; delay_ms = -1;
goto again; goto again;
} }
......
...@@ -27,17 +27,17 @@ int posix_recv_packet(struct pp_instance *ppi, void *pkt, int len) ...@@ -27,17 +27,17 @@ int posix_recv_packet(struct pp_instance *ppi, void *pkt, int len)
struct pp_channel *ch1 = NULL, *ch2 = NULL; struct pp_channel *ch1 = NULL, *ch2 = NULL;
switch (ch_check_stat) { switch (ch_check_stat) {
case 0: case 0:
ch1 = &(ppi->net_path->evt_ch); ch1 = &(ppi->net_path->evt_ch);
ch2 = &(ppi->net_path->gen_ch); ch2 = &(ppi->net_path->gen_ch);
break; break;
case 1: case 1:
ch1 = &(ppi->net_path->gen_ch); ch1 = &(ppi->net_path->gen_ch);
ch2 = &(ppi->net_path->evt_ch); ch2 = &(ppi->net_path->evt_ch);
break; break;
default: default:
/* Impossible! */ /* Impossible! */
break; break;
} }
if (ch1->pkt_present) if (ch1->pkt_present)
...@@ -83,7 +83,7 @@ int posix_open_ch(struct pp_instance *ppi, char *ifname) ...@@ -83,7 +83,7 @@ int posix_open_ch(struct pp_instance *ppi, char *ifname)
} }
/* hw interface information */ /* hw interface information */
memset (&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, ifname); strcpy(ifr.ifr_name, ifname);
if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0) { if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0) {
pp_diag_error_str2(ppi, "SIOCGIFINDEX", strerror(errno)); pp_diag_error_str2(ppi, "SIOCGIFINDEX", strerror(errno));
...@@ -130,7 +130,7 @@ int posix_net_init(struct pp_instance *ppi) ...@@ -130,7 +130,7 @@ int posix_net_init(struct pp_instance *ppi)
* We must decide how generic we want to be. Will we ever handle * We must decide how generic we want to be. Will we ever handle
* non-udp? Probably yes. * non-udp? Probably yes.
*/ */
posix_open_ch(ppi,ifname); /* FIXME: to be called twice, one for evt, posix_open_ch(ppi, ifname); /* FIXME: to be called twice, one for evt,
* one for general ? */ * one for general ? */
return 0; return 0;
} }
...@@ -184,12 +184,12 @@ int posix_net_check_pkt(struct pp_instance *ppi, int delay_ms) ...@@ -184,12 +184,12 @@ int posix_net_check_pkt(struct pp_instance *ppi, int delay_ms)
if (i == 0) if (i == 0)
goto _end; goto _end;
if (FD_ISSET(ppi->net_path->gen_ch.fd,&set)) { if (FD_ISSET(ppi->net_path->gen_ch.fd, &set)) {
ret++; ret++;
ppi->net_path->gen_ch.pkt_present = 1; ppi->net_path->gen_ch.pkt_present = 1;
} }
if (FD_ISSET(ppi->net_path->evt_ch.fd,&set)) { if (FD_ISSET(ppi->net_path->evt_ch.fd, &set)) {
ret++; ret++;
ppi->net_path->evt_ch.pkt_present = 1; ppi->net_path->evt_ch.pkt_present = 1;
} }
......
...@@ -24,7 +24,8 @@ int main(int argc, char **argv) ...@@ -24,7 +24,8 @@ int main(int argc, char **argv)
* To keep things simple, just run one thing for one interface. * To keep things simple, just run one thing for one interface.
*/ */
ifname = getenv("PPROTO_IF"); ifname = getenv("PPROTO_IF");
if (!ifname) ifname = "eth0"; if (!ifname)
ifname = "eth0";
/* We are hosted, so we can allocate */ /* We are hosted, so we can allocate */
ppi = calloc(1, sizeof(*ppi)); ppi = calloc(1, sizeof(*ppi));
...@@ -50,12 +51,12 @@ int main(int argc, char **argv) ...@@ -50,12 +51,12 @@ int main(int argc, char **argv)
) )
exit(__LINE__); exit(__LINE__);
if (posix_open_ch(ppi, ifname)) { if (posix_open_ch(ppi, ifname))
pp_diag_fatal(ppi, "open_ch", strerror(errno)); pp_diag_fatal(ppi, "open_ch", strerror(errno));
}
pp_open_instance(ppi, NULL); pp_open_instance(ppi, NULL);
pp_parse_cmdline(ppi,argc,argv); pp_parse_cmdline(ppi, argc, argv);
posix_main_loop(ppi); posix_main_loop(ppi);
return 0; /* never reached */ return 0; /* never reached */
......
...@@ -31,7 +31,7 @@ extern int posix_timer_init(struct pp_instance *ppi) ...@@ -31,7 +31,7 @@ extern int posix_timer_init(struct pp_instance *ppi)
for (i = 0; i < PP_TIMER_ARRAY_SIZE; i++) { for (i = 0; i < PP_TIMER_ARRAY_SIZE; i++) {
t = calloc(1,sizeof(*t)); t = calloc(1, sizeof(*t));
if (!t) if (!t)
return -1; return -1;
......
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
* These are the functions provided by the various posix files * These are the functions provided by the various posix files
*/ */
struct posix_arch_data struct posix_arch_data {
{
struct timeval tv; struct timeval tv;
}; };
......
...@@ -45,7 +45,7 @@ void spec_main_loop(struct pp_instance *ppi) ...@@ -45,7 +45,7 @@ void spec_main_loop(struct pp_instance *ppi)
if (i < sizeof(struct pp_packet) /* or minimum of all pckts */) if (i < sizeof(struct pp_packet) /* or minimum of all pckts */)
continue; continue;
/* Warning: PP_PROTO_NR is endian-agnostic by design */ /* Warning: PP_PROTO_NR is endian-agnostic by design */
if ( ((struct spec_ethhdr *)packet)->h_proto != if (((struct spec_ethhdr *)packet)->h_proto !=
htons(PP_PROTO_NR)) htons(PP_PROTO_NR))
continue; continue;
delay_ms = pp_state_machine(ppi, packet, i); delay_ms = pp_state_machine(ppi, packet, i);
......
...@@ -13,11 +13,12 @@ void pp_puts(const char *s) ...@@ -13,11 +13,12 @@ void pp_puts(const char *s)
int pp_strnlen(const char *s, int maxlen) int pp_strnlen(const char *s, int maxlen)
{ {
int len = 0; int len = 0;
while (*(s++)) len++; while (*(s++))
len++;
return len; return len;
} }
void *pp_memcpy(void * dest, const void *src, int count) void *pp_memcpy(void *dest, const void *src, int count)
{ {
/* from u-boot-1.1.2 */ /* from u-boot-1.1.2 */
char *tmp = (char *) dest, *s = (char *) src; char *tmp = (char *) dest, *s = (char *) src;
......
...@@ -13,7 +13,7 @@ int spec_open_ch(struct pp_instance *ppi) ...@@ -13,7 +13,7 @@ int spec_open_ch(struct pp_instance *ppi)
uint8_t fake_addr[] = {0x00, 0x10, 0x20, 0x30, 0x40, 0x50}; uint8_t fake_addr[] = {0x00, 0x10, 0x20, 0x30, 0x40, 0x50};
ep_init(fake_addr); ep_init(fake_addr);
ep_enable(1,1); ep_enable(1, 1);
minic_init(); minic_init();
memcpy(ppi->ch.addr, fake_addr, 6); memcpy(ppi->ch.addr, fake_addr, 6);
...@@ -24,7 +24,7 @@ int spec_open_ch(struct pp_instance *ppi) ...@@ -24,7 +24,7 @@ int spec_open_ch(struct pp_instance *ppi)
/* To receive and send packets, we call the minic low-level stuff */ /* To receive and send packets, we call the minic low-level stuff */
int spec_recv_packet(struct pp_instance *ppi, void *pkt, int len) int spec_recv_packet(struct pp_instance *ppi, void *pkt, int len)
{ {
static int led = 0; static int led;
led ^= 1; /* blink one led at each rx event */ led ^= 1; /* blink one led at each rx event */
gpio_out(GPIO_PIN_LED_LINK, led); gpio_out(GPIO_PIN_LED_LINK, led);
...@@ -33,7 +33,7 @@ int spec_recv_packet(struct pp_instance *ppi, void *pkt, int len) ...@@ -33,7 +33,7 @@ int spec_recv_packet(struct pp_instance *ppi, void *pkt, int len)
int spec_send_packet(struct pp_instance *ppi, void *pkt, int len) int spec_send_packet(struct pp_instance *ppi, void *pkt, int len)
{ {
static int led = 0; static int led;
led ^= 1; /* blink the other led at each tx event */ led ^= 1; /* blink the other led at each tx event */
gpio_out(GPIO_PIN_LED_STATUS, led); gpio_out(GPIO_PIN_LED_STATUS, led);
...@@ -41,6 +41,6 @@ int spec_send_packet(struct pp_instance *ppi, void *pkt, int len) ...@@ -41,6 +41,6 @@ int spec_send_packet(struct pp_instance *ppi, void *pkt, int len)
} }
int pp_recv_packet(struct pp_instance *ppi, void *pkt, int len) int pp_recv_packet(struct pp_instance *ppi, void *pkt, int len)
__attribute__((alias("spec_recv_packet"))); __attribute__((alias("spec_recv_packet")));
int pp_send_packet(struct pp_instance *ppi, void *pkt, int len) int pp_send_packet(struct pp_instance *ppi, void *pkt, int len)
__attribute__((alias("spec_send_packet"))); __attribute__((alias("spec_send_packet")));
...@@ -52,9 +52,9 @@ extern int ep_cal_pattern_disable(); ...@@ -52,9 +52,9 @@ extern int ep_cal_pattern_disable();
/* other network lstuff, bah.... */ /* other network lstuff, bah.... */
struct spec_ethhdr { struct spec_ethhdr {
unsigned char h_dest[6]; unsigned char h_dest[6];
unsigned char h_source[6]; unsigned char h_source[6];
uint16_t h_proto; uint16_t h_proto;
} __attribute__((packed)); } __attribute__((packed));
/* Low-level details (from board.h in wr-core-tools) */ /* Low-level details (from board.h in wr-core-tools) */
...@@ -65,7 +65,7 @@ struct spec_ethhdr { ...@@ -65,7 +65,7 @@ struct spec_ethhdr {
#define BASE_PPSGEN 0x50000 #define BASE_PPSGEN 0x50000
#define BASE_EP 0x20000 #define BASE_EP 0x20000
#define BASE_MINIC 0x10000 #define BASE_MINIC 0x10000
#define BASE_SOFTPLL 0x40000 #define BASE_SOFTPLL 0x40000
#define CPU_CLOCK 62500000ULL #define CPU_CLOCK 62500000ULL
......
...@@ -18,9 +18,8 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen) ...@@ -18,9 +18,8 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
struct pp_state_table_item *ip; struct pp_state_table_item *ip;
int state, err; int state, err;
if (packet) { if (packet)
msg_unpack_header(packet, ppi); msg_unpack_header(packet, ppi);
}
state = ppi->state; state = ppi->state;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment