[formatting] run everything through codestyle
Almost nothing changes here except moving braces to the same line as the function declaration. Everything else is largely whitespace changes and a few dangling files with tab indents. See scripts/codestyle
This commit is contained in:
@@ -42,8 +42,7 @@ struct bootimage {
|
||||
uint32_t next_offset;
|
||||
};
|
||||
|
||||
bootimage *bootimage_init(void)
|
||||
{
|
||||
bootimage *bootimage_init(void) {
|
||||
bootimage *img;
|
||||
|
||||
if ((img = malloc(sizeof(bootimage))) == NULL) {
|
||||
@@ -63,8 +62,7 @@ bootimage *bootimage_init(void)
|
||||
return img;
|
||||
}
|
||||
|
||||
bootentry_data *bootimage_add_string(bootimage *img, unsigned kind, const char *s)
|
||||
{
|
||||
bootentry_data *bootimage_add_string(bootimage *img, unsigned kind, const char *s) {
|
||||
unsigned n = img->count;
|
||||
int len = strlen(s);
|
||||
if (img->count == 64) return NULL;
|
||||
@@ -76,8 +74,7 @@ bootentry_data *bootimage_add_string(bootimage *img, unsigned kind, const char *
|
||||
return &(img->entry[n].data);
|
||||
}
|
||||
|
||||
bootentry_file *bootimage_add_filedata(bootimage *img, unsigned type, void *data, unsigned len)
|
||||
{
|
||||
bootentry_file *bootimage_add_filedata(bootimage *img, unsigned type, void *data, unsigned len) {
|
||||
unsigned n = img->count;
|
||||
if (img->count == 64) return NULL;
|
||||
img->count++;
|
||||
@@ -100,8 +97,7 @@ bootentry_file *bootimage_add_filedata(bootimage *img, unsigned type, void *data
|
||||
return &(img->entry[n].file);
|
||||
}
|
||||
|
||||
void bootimage_done(bootimage *img)
|
||||
{
|
||||
void bootimage_done(bootimage *img) {
|
||||
unsigned sz = img->next_offset;
|
||||
if (sz & 4095) {
|
||||
sz += (4096 - (sz & 4095));
|
||||
@@ -111,8 +107,7 @@ void bootimage_done(bootimage *img)
|
||||
SHA256_hash((void *) &(img->entry[1]), 4096 - 64, img->entry[0].file.sha256);
|
||||
}
|
||||
|
||||
static int writex(int fd, void *data, size_t len)
|
||||
{
|
||||
static int writex(int fd, void *data, size_t len) {
|
||||
int r;
|
||||
char *x = data;
|
||||
while (len > 0) {
|
||||
@@ -131,8 +126,7 @@ static int writex(int fd, void *data, size_t len)
|
||||
|
||||
static uint8_t filler[4096] = { 0, };
|
||||
|
||||
int bootimage_write(bootimage *img, int fd)
|
||||
{
|
||||
int bootimage_write(bootimage *img, int fd) {
|
||||
unsigned off = 4096;
|
||||
unsigned n, s;
|
||||
if (writex(fd, img->entry, 4096)) {
|
||||
@@ -158,8 +152,7 @@ int bootimage_write(bootimage *img, int fd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *load_file(const char *fn, size_t *len)
|
||||
{
|
||||
static void *load_file(const char *fn, size_t *len) {
|
||||
off_t sz;
|
||||
void *data = NULL;
|
||||
char *x;
|
||||
@@ -205,8 +198,7 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bootentry_file *bootimage_add_file(bootimage *img, unsigned type, const char *fn)
|
||||
{
|
||||
bootentry_file *bootimage_add_file(bootimage *img, unsigned type, const char *fn) {
|
||||
unsigned char *data;
|
||||
size_t len;
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@
|
||||
#include "network.h"
|
||||
#include "../app/lkboot/lkboot_protocol.h"
|
||||
|
||||
static int readx(int s, void *_data, int len)
|
||||
{
|
||||
static int readx(int s, void *_data, int len) {
|
||||
char *data = _data;
|
||||
int r;
|
||||
while (len > 0) {
|
||||
@@ -53,8 +52,7 @@ static int readx(int s, void *_data, int len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int upload(int s, int txfd, size_t txlen, int do_endian_swap)
|
||||
{
|
||||
static int upload(int s, int txfd, size_t txlen, int do_endian_swap) {
|
||||
int err = 0;
|
||||
msg_hdr_t hdr;
|
||||
|
||||
@@ -117,8 +115,7 @@ done:
|
||||
return err;
|
||||
}
|
||||
|
||||
static off_t trim_fpga_image(int fd, off_t len)
|
||||
{
|
||||
static off_t trim_fpga_image(int fd, off_t len) {
|
||||
/* fd should be at start of bitfile, seek until the
|
||||
* ff ff ff ff aa 99 55 66 pattern is found and subtract
|
||||
* the number of bytes read until pattern found.
|
||||
@@ -148,8 +145,7 @@ static off_t trim_fpga_image(int fd, off_t len)
|
||||
|
||||
#define DCC_SUBPROCESS "zynq-dcc"
|
||||
|
||||
static int start_dcc_subprocess(int *fd_in, int *fd_out)
|
||||
{
|
||||
static int start_dcc_subprocess(int *fd_in, int *fd_out) {
|
||||
int outpipe[2];
|
||||
if (pipe(outpipe) != 0)
|
||||
return -1;
|
||||
@@ -191,14 +187,12 @@ static int start_dcc_subprocess(int *fd_in, int *fd_out)
|
||||
static unsigned char replybuf[REPLYMAX];
|
||||
static unsigned replylen = 0;
|
||||
|
||||
unsigned lkboot_get_reply(void **ptr)
|
||||
{
|
||||
unsigned lkboot_get_reply(void **ptr) {
|
||||
*ptr = replybuf;
|
||||
return replylen;
|
||||
}
|
||||
|
||||
int lkboot_txn(const char *host, const char *_cmd, int txfd, const char *args)
|
||||
{
|
||||
int lkboot_txn(const char *host, const char *_cmd, int txfd, const char *args) {
|
||||
msg_hdr_t hdr;
|
||||
char cmd[128];
|
||||
char tmp[65536];
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
|
||||
#include "liblkboot.h"
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
void usage(void) {
|
||||
fprintf(stderr,
|
||||
"usage: lkboot <hostname> <command> ...\n"
|
||||
"\n"
|
||||
@@ -53,8 +52,7 @@ void usage(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void printsysparam(void *data, int len)
|
||||
{
|
||||
void printsysparam(void *data, int len) {
|
||||
unsigned char *x = data;
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
@@ -70,8 +68,7 @@ printhex:
|
||||
fprintf(stderr, " ]\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int main(int argc, char **argv) {
|
||||
const char *host = argv[1];
|
||||
const char *cmd = argv[2];
|
||||
const char *args = argv[3];
|
||||
|
||||
@@ -47,8 +47,7 @@ static struct {
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
void usage(const char *binary)
|
||||
{
|
||||
void usage(const char *binary) {
|
||||
unsigned n;
|
||||
fprintf(stderr, "usage:\n");
|
||||
fprintf(stderr, "%s [-h] [-o <output file] section:file ...\n\n", binary);
|
||||
@@ -68,8 +67,7 @@ void usage(const char *binary)
|
||||
}
|
||||
}
|
||||
|
||||
int process(bootimage *img, char *cmd, char *arg)
|
||||
{
|
||||
int process(bootimage *img, char *cmd, char *arg) {
|
||||
unsigned n;
|
||||
|
||||
for (n = 0; types[n].cmd != NULL; n++) {
|
||||
@@ -92,8 +90,7 @@ int process(bootimage *img, char *cmd, char *arg)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int main(int argc, char **argv) {
|
||||
const char *binary = argv[0];
|
||||
bootimage *img;
|
||||
int fd;
|
||||
|
||||
32
tools/nettool.py
Executable file
32
tools/nettool.py
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import socket
|
||||
import time
|
||||
|
||||
print("hello")
|
||||
|
||||
parser = argparse.ArgumentParser(description="Network Testing Tools");
|
||||
parser.add_argument('-a', '--address', nargs=1, help='ip or dns address of host',
|
||||
default='192.168.0.99')
|
||||
parser.add_argument('-p', '--port', nargs=1, help='port on host',
|
||||
default=[1234], type=int)
|
||||
|
||||
args = parser.parse_args()
|
||||
print(args)
|
||||
|
||||
print("connecting to {}, port {}".format(args.address, args.port[0]))
|
||||
s = socket.create_connection((args.address, args.port[0]))
|
||||
print(s)
|
||||
|
||||
s.send(b"what what");
|
||||
|
||||
while True:
|
||||
time.sleep(100)
|
||||
data = s.recv(65536)
|
||||
if not data:
|
||||
break
|
||||
|
||||
s.close()
|
||||
|
||||
# vim: set ts=4 sw=4 expandtab:
|
||||
@@ -28,8 +28,7 @@
|
||||
|
||||
#include "network.h"
|
||||
|
||||
in_addr_t lookup_hostname(const char *hostname)
|
||||
{
|
||||
in_addr_t lookup_hostname(const char *hostname) {
|
||||
int err;
|
||||
struct addrinfo *info, *temp;
|
||||
in_addr_t addr = 0;
|
||||
@@ -61,8 +60,7 @@ in_addr_t lookup_hostname(const char *hostname)
|
||||
return addr;
|
||||
}
|
||||
|
||||
static int inet_listen(in_addr_t addr, int type, unsigned port, int shared)
|
||||
{
|
||||
static int inet_listen(in_addr_t addr, int type, unsigned port, int shared) {
|
||||
struct sockaddr_in sa;
|
||||
int s;
|
||||
if ((s = socket(AF_INET, type, 0)) < 0) {
|
||||
@@ -84,8 +82,7 @@ static int inet_listen(in_addr_t addr, int type, unsigned port, int shared)
|
||||
return s;
|
||||
}
|
||||
|
||||
static int inet_connect(in_addr_t addr, int type, unsigned port)
|
||||
{
|
||||
static int inet_connect(in_addr_t addr, int type, unsigned port) {
|
||||
struct sockaddr_in sa;
|
||||
int s;
|
||||
if ((s = socket(AF_INET, type, 0)) < 0) {
|
||||
@@ -106,22 +103,18 @@ static int inet_connect(in_addr_t addr, int type, unsigned port)
|
||||
return s;
|
||||
}
|
||||
|
||||
int udp_listen(in_addr_t addr, unsigned port, int shared)
|
||||
{
|
||||
int udp_listen(in_addr_t addr, unsigned port, int shared) {
|
||||
return inet_listen(addr, SOCK_DGRAM, port, shared);
|
||||
}
|
||||
|
||||
int udp_connect(in_addr_t addr, unsigned port)
|
||||
{
|
||||
int udp_connect(in_addr_t addr, unsigned port) {
|
||||
return inet_connect(addr, SOCK_DGRAM, port);
|
||||
}
|
||||
|
||||
int tcp_listen(in_addr_t addr, unsigned port)
|
||||
{
|
||||
int tcp_listen(in_addr_t addr, unsigned port) {
|
||||
return inet_listen(addr, SOCK_STREAM, port, 0);
|
||||
}
|
||||
|
||||
int tcp_connect(in_addr_t addr, unsigned port)
|
||||
{
|
||||
int tcp_connect(in_addr_t addr, unsigned port) {
|
||||
return inet_connect(addr, SOCK_STREAM, port);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user