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)
int pp_strnlen(const char *s, int maxlen)
{
int len = 0;
while (*(s++)) len++;
while (*(s++))
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 */
char *tmp = (char *) dest, *s = (char *) src;
......
......@@ -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_send(int fd, void *pkt, int plen, int flags);
extern int bare_errno;
/* structures passed to syscalls */
......@@ -42,8 +41,7 @@ struct bare_sockaddr {
};
struct bare_ifreq {
union
{
union {
char ifrn_name[IFNAMSIZ];
} ifr_ifrn;
......@@ -68,7 +66,7 @@ struct bare_sockaddr_ll {
/* other network stuff, bah.... */
struct bare_ethhdr {
unsigned char h_dest[6];
unsigned char h_source[6];
uint16_t h_proto;
unsigned char h_dest[6];
unsigned char h_source[6];
uint16_t h_proto;
} __attribute__((packed));
......@@ -10,11 +10,11 @@
#include <pptp/diag.h>
#include "bare-linux.h"
extern int __bss_start, __bss_end;
void pptp_clear_bss(void)
{
int *ptr;
extern int __bss_start, __bss_end;
for (ptr = &__bss_start; ptr < &__bss_end; ptr++)
*ptr = 0;
......@@ -34,7 +34,7 @@ void pptp_main(void)
pp_diag_error(ppi, bare_errno);
pp_diag_fatal(ppi, "open_ch", "");
}
pp_open_instance(ppi,0);
pp_open_instance(ppi, 0);
bare_main_loop(ppi);
}
......@@ -4,15 +4,15 @@
/* Architecture-specific defines, included by top-level stuff */
/* please note that these have multiple evaluation of the argument */
#define htons(x) __bswap_16(x)
#define __bswap_16(x) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
#define htons(x) __bswap_16(x)
#define __bswap_16(x) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
#define htonl(x) __bswap_32(x)
#define __bswap_32(x) ( \
(((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
(((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
(((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
(((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24))
#define htonl(x) __bswap_32(x)
#define __bswap_32(x) ( \
(((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
(((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
(((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
(((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24))
#define ntohs htons
#define ntohl htonl
......
......@@ -10,11 +10,17 @@
#include "bare-linux.h"
/* Define other hackish stuff */
typedef struct {unsigned long bits[1024/32];} bare_fd_set;
#define FD_ZERO(p) memset(p, 0, sizeof(p))
#define FD_SET(bit, p) ((p)->bits[0] |= (1 << (bit)))
struct bare_fd_set {
unsigned long bits[1024/32];
};
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
......@@ -29,7 +35,7 @@ void bare_main_loop(struct pp_instance *ppi)
*/
delay_ms = pp_state_machine(ppi, NULL, 0);
while (1) {
bare_fd_set set;
struct bare_fd_set set;
int i, maxfd;
struct bare_timeval tv;
unsigned char packet[1500];
......@@ -65,7 +71,7 @@ void bare_main_loop(struct pp_instance *ppi)
*/
i = bare_recv_packet(ppi, packet, sizeof(packet));
/* 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))
goto again;
......
/*
* Alessandro Rubini for CERN, 2011 -- public domain
*/
#include <asm/unistd.h>
#include <linux/unistd.h>
#include <pptp/pptp.h>
#include "bare-linux.h"
......@@ -10,9 +10,9 @@
int bare_errno;
struct sel_arg_struct {
unsigned long n;
void *inp, *outp, *exp;
void *tvp;
unsigned long n;
void *inp, *outp, *exp;
void *tvp;
};
/*
......@@ -49,24 +49,24 @@ int sys_select(int max, void *in, void *out, void *exc, void *tout)
}
/* i386 has the socketcall thing. Bah! */
#define SYS_SOCKET 1 /* sys_socket(2) */
#define SYS_BIND 2 /* sys_bind(2) */
#define SYS_CONNECT 3 /* sys_connect(2) */
#define SYS_LISTEN 4 /* sys_listen(2) */
#define SYS_ACCEPT 5 /* sys_accept(2) */
#define SYS_GETSOCKNAME 6 /* sys_getsockname(2) */
#define SYS_GETPEERNAME 7 /* sys_getpeername(2) */
#define SYS_SOCKETPAIR 8 /* sys_socketpair(2) */
#define SYS_SEND 9 /* sys_send(2) */
#define SYS_RECV 10 /* sys_recv(2) */
#define SYS_SENDTO 11 /* sys_sendto(2) */
#define SYS_RECVFROM 12 /* sys_recvfrom(2) */
#define SYS_SHUTDOWN 13 /* sys_shutdown(2) */
#define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */
#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
#define SYS_SENDMSG 16 /* sys_sendmsg(2) */
#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
#define SYS_PACCEPT 18 /* sys_paccept(2) */
#define SYS_SOCKET 1 /* sys_socket(2) */
#define SYS_BIND 2 /* sys_bind(2) */
#define SYS_CONNECT 3 /* sys_connect(2) */
#define SYS_LISTEN 4 /* sys_listen(2) */
#define SYS_ACCEPT 5 /* sys_accept(2) */
#define SYS_GETSOCKNAME 6 /* sys_getsockname(2) */
#define SYS_GETPEERNAME 7 /* sys_getpeername(2) */
#define SYS_SOCKETPAIR 8 /* sys_socketpair(2) */
#define SYS_SEND 9 /* sys_send(2) */
#define SYS_RECV 10 /* sys_recv(2) */
#define SYS_SENDTO 11 /* sys_sendto(2) */
#define SYS_RECVFROM 12 /* sys_recvfrom(2) */
#define SYS_SHUTDOWN 13 /* sys_shutdown(2) */
#define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */
#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
#define SYS_SENDMSG 16 /* sys_sendmsg(2) */
#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
#define SYS_PACCEPT 18 /* sys_paccept(2) */
static unsigned long args[4];
......@@ -74,7 +74,7 @@ int sys_socket(int domain, int type, int proto)
{
/*
* 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...
*/
args[0] = domain;
......
......@@ -52,7 +52,7 @@ void posix_main_loop(struct pp_instance *ppi)
}
/* 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;
goto again;
}
......
......@@ -27,17 +27,17 @@ int posix_recv_packet(struct pp_instance *ppi, void *pkt, int len)
struct pp_channel *ch1 = NULL, *ch2 = NULL;
switch (ch_check_stat) {
case 0:
ch1 = &(ppi->net_path->evt_ch);
ch2 = &(ppi->net_path->gen_ch);
break;
case 1:
ch1 = &(ppi->net_path->gen_ch);
ch2 = &(ppi->net_path->evt_ch);
break;
default:
/* Impossible! */
break;
case 0:
ch1 = &(ppi->net_path->evt_ch);
ch2 = &(ppi->net_path->gen_ch);
break;
case 1:
ch1 = &(ppi->net_path->gen_ch);
ch2 = &(ppi->net_path->evt_ch);
break;
default:
/* Impossible! */
break;
}
if (ch1->pkt_present)
......@@ -83,7 +83,7 @@ int posix_open_ch(struct pp_instance *ppi, char *ifname)
}
/* hw interface information */
memset (&ifr, 0, sizeof(ifr));
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, ifname);
if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0) {
pp_diag_error_str2(ppi, "SIOCGIFINDEX", strerror(errno));
......@@ -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
* 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 ? */
return 0;
}
......@@ -184,12 +184,12 @@ int posix_net_check_pkt(struct pp_instance *ppi, int delay_ms)
if (i == 0)
goto _end;
if (FD_ISSET(ppi->net_path->gen_ch.fd,&set)) {
if (FD_ISSET(ppi->net_path->gen_ch.fd, &set)) {
ret++;
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++;
ppi->net_path->evt_ch.pkt_present = 1;
}
......
......@@ -24,7 +24,8 @@ int main(int argc, char **argv)
* To keep things simple, just run one thing for one interface.
*/
ifname = getenv("PPROTO_IF");
if (!ifname) ifname = "eth0";
if (!ifname)
ifname = "eth0";
/* We are hosted, so we can allocate */
ppi = calloc(1, sizeof(*ppi));
......@@ -50,12 +51,12 @@ int main(int argc, char **argv)
)
exit(__LINE__);
if (posix_open_ch(ppi, ifname)) {
if (posix_open_ch(ppi, ifname))
pp_diag_fatal(ppi, "open_ch", strerror(errno));
}
pp_open_instance(ppi, NULL);
pp_parse_cmdline(ppi,argc,argv);
pp_parse_cmdline(ppi, argc, argv);
posix_main_loop(ppi);
return 0; /* never reached */
......
......@@ -31,7 +31,7 @@ extern int posix_timer_init(struct pp_instance *ppi)
for (i = 0; i < PP_TIMER_ARRAY_SIZE; i++) {
t = calloc(1,sizeof(*t));
t = calloc(1, sizeof(*t));
if (!t)
return -1;
......
......@@ -6,8 +6,7 @@
* These are the functions provided by the various posix files
*/
struct posix_arch_data
{
struct posix_arch_data {
struct timeval tv;
};
......
......@@ -45,7 +45,7 @@ void spec_main_loop(struct pp_instance *ppi)
if (i < sizeof(struct pp_packet) /* or minimum of all pckts */)
continue;
/* 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))
continue;
delay_ms = pp_state_machine(ppi, packet, i);
......
......@@ -13,11 +13,12 @@ void pp_puts(const char *s)
int pp_strnlen(const char *s, int maxlen)
{
int len = 0;
while (*(s++)) len++;
while (*(s++))
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 */
char *tmp = (char *) dest, *s = (char *) src;
......
......@@ -13,7 +13,7 @@ int spec_open_ch(struct pp_instance *ppi)
uint8_t fake_addr[] = {0x00, 0x10, 0x20, 0x30, 0x40, 0x50};
ep_init(fake_addr);
ep_enable(1,1);
ep_enable(1, 1);
minic_init();
memcpy(ppi->ch.addr, fake_addr, 6);
......@@ -24,7 +24,7 @@ int spec_open_ch(struct pp_instance *ppi)
/* To receive and send packets, we call the minic low-level stuff */
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 */
gpio_out(GPIO_PIN_LED_LINK, led);
......@@ -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)
{
static int led = 0;
static int led;
led ^= 1; /* blink the other led at each tx event */
gpio_out(GPIO_PIN_LED_STATUS, led);
......@@ -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)
__attribute__((alias("spec_recv_packet")));
__attribute__((alias("spec_recv_packet")));
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();
/* other network lstuff, bah.... */
struct spec_ethhdr {
unsigned char h_dest[6];
unsigned char h_source[6];
uint16_t h_proto;
unsigned char h_dest[6];
unsigned char h_source[6];
uint16_t h_proto;
} __attribute__((packed));
/* Low-level details (from board.h in wr-core-tools) */
......@@ -65,7 +65,7 @@ struct spec_ethhdr {
#define BASE_PPSGEN 0x50000
#define BASE_EP 0x20000
#define BASE_MINIC 0x10000
#define BASE_SOFTPLL 0x40000
#define BASE_SOFTPLL 0x40000
#define CPU_CLOCK 62500000ULL
......
......@@ -18,9 +18,8 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
struct pp_state_table_item *ip;
int state, err;
if (packet) {
if (packet)
msg_unpack_header(packet, ppi);
}
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