Hi,
just some patches which should address some of the checkpatch errors/warnings. It doesn't address things in list.h, debugfs.(c|h) or vis/gpsd.
Kind regards, Sven
Signed-off-by: Sven Eckelmann sven@narfation.org --- batadv_query.c | 6 +++--- hash.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/batadv_query.c b/batadv_query.c index 473ab40..2a607b9 100644 --- a/batadv_query.c +++ b/batadv_query.c @@ -91,7 +91,7 @@ int ipv6_to_mac(const struct in6_addr *addr, struct ether_addr *mac) int batadv_interface_check(const char *mesh_iface) { char *debugfs_mnt; - char full_path[MAX_PATH+1]; + char full_path[MAX_PATH + 1]; FILE *f;
debugfs_mnt = debugfs_mount(NULL); @@ -133,7 +133,7 @@ struct ether_addr *translate_mac(const char *mesh_iface, struct ether_addr *mac) tg_via, tg_originator, } pos; - char full_path[MAX_PATH+1]; + char full_path[MAX_PATH + 1]; char *debugfs_mnt; static struct ether_addr in_mac; struct ether_addr *mac_result, *mac_tmp; @@ -215,7 +215,7 @@ uint8_t get_tq(const char *mesh_iface, struct ether_addr *mac) orig_tqstart, orig_tqvalue, } pos; - char full_path[MAX_PATH+1]; + char full_path[MAX_PATH + 1]; char *debugfs_mnt; static struct ether_addr in_mac; struct ether_addr *mac_tmp; diff --git a/hash.c b/hash.c index 87e8484..685842f 100644 --- a/hash.c +++ b/hash.c @@ -204,7 +204,7 @@ struct hashtable_t *hash_new(int size, hashdata_compare_cb compare, return NULL;
hash->size = size; - hash->table = debugMalloc(sizeof(struct element_t *)*size, 303); + hash->table = debugMalloc(sizeof(struct element_t *) * size, 303);
if (!hash->table) { debugFree(hash, 1305);
Signed-off-by: Sven Eckelmann sven@narfation.org --- batadv_query.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/batadv_query.c b/batadv_query.c index 2a607b9..c289b80 100644 --- a/batadv_query.c +++ b/batadv_query.c @@ -269,10 +269,10 @@ uint8_t get_tq(const char *mesh_iface, struct ether_addr *mac) } else if (strlen(token) == 1) { pos = orig_tqvalue; break; - } else { - /* fall through */ - token++; } + + token++; + /* fall through */ case orig_tqvalue: if (token[strlen(token) - 1] != ')') { line_invalid = 1;
Signed-off-by: Sven Eckelmann sven@narfation.org --- batadv_query.h | 3 ++- client.c | 4 +++- hash.c | 13 +++++++------ 3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/batadv_query.h b/batadv_query.h index 6b938ea..8991ee9 100644 --- a/batadv_query.h +++ b/batadv_query.h @@ -24,7 +24,8 @@ #include <stdint.h> #include <netinet/in.h>
-struct ether_addr *translate_mac(const char *mesh_iface, struct ether_addr *mac); +struct ether_addr *translate_mac(const char *mesh_iface, + struct ether_addr *mac); uint8_t get_tq(const char *mesh_iface, struct ether_addr *mac); int batadv_interface_check(const char *mesh_iface); int mac_to_ipv6(const struct ether_addr *mac, struct in6_addr *addr); diff --git a/client.c b/client.c index 42dd4ad..f68a5b0 100644 --- a/client.c +++ b/client.c @@ -265,11 +265,13 @@ int alfred_client_change_interface(struct globals *globals) struct alfred_change_interface_v0 *change_interface; int ret, len; char *input, *token, *saveptr; + size_t interface_len;
if (unix_sock_open_client(globals)) return -1;
- if (strlen(globals->change_interface) > sizeof(change_interface->ifaces)) { + interface_len = strlen(globals->change_interface); + if (interface_len > sizeof(change_interface->ifaces)) { fprintf(stderr, "%s: interface name list too long, not changing\n", __func__); return 0; diff --git a/hash.c b/hash.c index 685842f..a53bb9c 100644 --- a/hash.c +++ b/hash.c @@ -292,12 +292,13 @@ void *hash_remove(struct hashtable_t *hash, void *data)
while (hash_it_t.bucket != NULL) { if (hash->compare(hash_it_t.bucket->data, data)) { - int bucket_same; - bucket_same = (hash_it_t.bucket == - hash->table[hash_it_t.index]); - hash_it_t.first_bucket = (bucket_same ? - &hash->table[hash_it_t.index] : - NULL); + struct element_t **first_bucket = NULL; + + if (hash_it_t.bucket == hash->table[hash_it_t.index]) + first_bucket = &hash->table[hash_it_t.index]; + + hash_it_t.first_bucket = first_bucket; + return hash_remove_bucket(hash, &hash_it_t); }
Signed-off-by: Sven Eckelmann sven@narfation.org --- client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client.c b/client.c index f68a5b0..22b8439 100644 --- a/client.c +++ b/client.c @@ -145,7 +145,7 @@ recv_err: status = (struct alfred_status_v0 *)buf; fprintf(stderr, "Request failed with %d\n", status->tx.seqno);
- return status->tx.seqno;; + return status->tx.seqno; }
int alfred_client_set_data(struct globals *globals)
Signed-off-by: Sven Eckelmann sven@narfation.org --- README | 6 +++--- hash.h | 2 +- list.h | 2 +- send.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/README b/README index 2bb4f9b..7cef9f6 100644 --- a/README +++ b/README @@ -44,13 +44,13 @@ This will compile alfred, batadv-vis & alfred-gpsd. To install, use
If you don't want to compile batadv-vis, add the directive CONFIG_ALFRED_VIS=n:
- $ make CONFIG_ALFRED_VIS=n + $ make CONFIG_ALFRED_VIS=n $ make CONFIG_ALFRED_VIS=n install
If you don't want to compile alfred-gpsd, add the directive CONFIG_ALFRED_GPSD=n:
- $ make CONFIG_ALFRED_GPSD=n + $ make CONFIG_ALFRED_GPSD=n $ make CONFIG_ALFRED_GPSD=n install
@@ -254,7 +254,7 @@ To get JSON formatted output, use: { "source" : "8e:4c:77:b3:65:b4", "tpv" : {"class":"TPV","device":"command line","time":"2013-10-01T10:43:05.129Z","lat":48.858222,"lon":2.2945,"alt":358.000000,"mode":3} } ]
-See gpsd_json(5) for documentation of the tpv object. +See gpsd_json(5) for documentation of the tpv object.
Running alfred as non-root user ------------------------------- diff --git a/hash.h b/hash.h index aa27f25..c7259c1 100644 --- a/hash.h +++ b/hash.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2006-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner diff --git a/list.h b/list.h index 4cfbfc6..2ac2c87 100644 --- a/list.h +++ b/list.h @@ -1,6 +1,6 @@ /* * Copyright (C) 1991-2013 linux kernel contributors - * + * * Linus Torvalds, ... * * This program is free software; you can redistribute it and/or diff --git a/send.c b/send.c index f1843fe..7e0f416 100644 --- a/send.c +++ b/send.c @@ -110,7 +110,7 @@ int push_data(struct globals *globals, struct interface *interface, }
/* send transaction txend packet */ - if (seqno > 0 || type_filter != NO_FILTER) { + if (seqno > 0 || type_filter != NO_FILTER) { status_end.header.type = ALFRED_STATUS_TXEND; status_end.header.version = ALFRED_VERSION; length = sizeof(status_end) - sizeof(status_end.header);
Signed-off-by: Sven Eckelmann sven@narfation.org --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c index e9821be..7ad4625 100644 --- a/main.c +++ b/main.c @@ -149,8 +149,8 @@ static struct globals *alfred_init(int argc, char *argv[]) {"interface", required_argument, NULL, 'i'}, {"master", no_argument, NULL, 'm'}, {"help", no_argument, NULL, 'h'}, - {"req-version", required_argument, NULL, 'V'}, - {"modeswitch", required_argument, NULL, 'M'}, + {"req-version", required_argument, NULL, 'V'}, + {"modeswitch", required_argument, NULL, 'M'}, {"change-interface", required_argument, NULL, 'I'}, {"unix-path", required_argument, NULL, 'u'}, {"version", no_argument, NULL, 'v'},
Signed-off-by: Sven Eckelmann sven@narfation.org --- hash.c | 3 +-- main.c | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/hash.c b/hash.c index a53bb9c..87588cd 100644 --- a/hash.c +++ b/hash.c @@ -142,10 +142,9 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash, iter->bucket = (*iter->first_bucket); iter->first_bucket = &hash->table[iter->index]; return iter; - } else { - iter->bucket = NULL; }
+ iter->bucket = NULL; }
} else if (iter->prev_bucket != NULL) { diff --git a/main.c b/main.c index 7ad4625..02553c0 100644 --- a/main.c +++ b/main.c @@ -265,19 +265,14 @@ int main(int argc, char *argv[]) switch (globals->clientmode) { case CLIENT_NONE: return alfred_server(globals); - break; case CLIENT_REQUEST_DATA: return alfred_client_request_data(globals); - break; case CLIENT_SET_DATA: return alfred_client_set_data(globals); - break; case CLIENT_MODESWITCH: return alfred_client_modeswitch(globals); - break; case CLIENT_CHANGE_INTERFACE: return alfred_client_change_interface(globals); - break; }
return 0;
Signed-off-by: Sven Eckelmann sven@narfation.org --- hash.c | 1 - hash.h | 2 -- packet.h | 1 - recv.c | 4 ---- send.c | 1 - server.c | 4 ---- unix_sock.c | 2 -- 7 files changed, 15 deletions(-)
diff --git a/hash.c b/hash.c index 87588cd..20034d6 100644 --- a/hash.c +++ b/hash.c @@ -19,7 +19,6 @@ * */
- #include "hash.h" #include <stdlib.h> #include <stdio.h> diff --git a/hash.h b/hash.h index c7259c1..ee01c0f 100644 --- a/hash.h +++ b/hash.h @@ -21,8 +21,6 @@ #ifndef _BATMAN_HASH_H #define _BATMAN_HASH_H
- - typedef int (*hashdata_compare_cb)(void *, void *); typedef int (*hashdata_choose_cb)(void *, int); typedef void (*hashdata_free_cb)(void *); diff --git a/packet.h b/packet.h index 27ee6e5..ceb6c79 100644 --- a/packet.h +++ b/packet.h @@ -158,7 +158,6 @@ struct alfred_change_interface_v0 { char ifaces[IFNAMSIZ * 16]; } __packed;
- /** * struct alfred_status_v0 - Status info of a transaction * @header: TLV header describing the complete packet diff --git a/recv.c b/recv.c index e0252eb..02d96c9 100644 --- a/recv.c +++ b/recv.c @@ -287,7 +287,6 @@ process_alfred_announce_master(struct globals *globals, return 0; }
- static int process_alfred_request(struct globals *globals, struct interface *interface, struct in6_addr *source, @@ -309,12 +308,10 @@ static int process_alfred_request(struct globals *globals, return 0; }
- static int process_alfred_status_txend(struct globals *globals, struct in6_addr *source, struct alfred_status_v0 *request) { - struct transaction_head search, *head; struct transaction_packet *transaction_packet, *safe; struct ether_addr mac; @@ -372,7 +369,6 @@ static int process_alfred_status_txend(struct globals *globals, return 0; }
- int recv_alfred_packet(struct globals *globals, struct interface *interface) { uint8_t buf[MAX_PAYLOAD]; diff --git a/send.c b/send.c index 7e0f416..3228d5c 100644 --- a/send.c +++ b/send.c @@ -126,7 +126,6 @@ int push_data(struct globals *globals, struct interface *interface, return 0; }
- int sync_data(struct globals *globals) { struct hash_it_t *hashit = NULL; diff --git a/server.c b/server.c index 1a3d876..ab6f4ec 100644 --- a/server.c +++ b/server.c @@ -102,8 +102,6 @@ static int tx_choose(void *d1, int size) return hash % size; }
- - static int create_hashes(struct globals *globals) { globals->data_hash = hash_new(128, data_compare, data_choose); @@ -351,5 +349,3 @@ int alfred_server(struct globals *globals) unix_sock_close(globals); return 0; } - - diff --git a/unix_sock.c b/unix_sock.c index 0707252..a3affdc 100644 --- a/unix_sock.c +++ b/unix_sock.c @@ -93,7 +93,6 @@ int unix_sock_open_client(struct globals *globals) return 0; }
- static int unix_sock_add_data(struct globals *globals, struct alfred_push_data_v0 *push, int client_sock) @@ -160,7 +159,6 @@ err: return ret; }
- static int unix_sock_req_data_reply(struct globals *globals, int client_sock, uint16_t id, uint8_t requested_type) {
Signed-off-by: Sven Eckelmann sven@narfation.org --- packet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packet.h b/packet.h index ceb6c79..5ecdf39 100644 --- a/packet.h +++ b/packet.h @@ -165,7 +165,7 @@ struct alfred_change_interface_v0 { * * The sequence number has a special meaning. Failure status packets use * it to store the error code. Success status packets store the number of - * transfered packets in it. + * transferred packets in it. * * Sent as unicast to the node requesting the data */
Signed-off-by: Sven Eckelmann sven@narfation.org --- hash.h | 2 +- send.c | 2 +- server.c | 2 +- unix_sock.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hash.h b/hash.h index ee01c0f..6e027bb 100644 --- a/hash.h +++ b/hash.h @@ -57,7 +57,7 @@ void hash_init(struct hashtable_t *hash);
/* allocates and clears the hash */ struct hashtable_t *hash_new(int size, hashdata_compare_cb compare, - hashdata_choose_cb choose); + hashdata_choose_cb choose);
/* remove bucket (this might be used in hash_iterate() if you already found * the bucket you want to delete and don't need the overhead to find it again diff --git a/send.c b/send.c index 3228d5c..cc55489 100644 --- a/send.c +++ b/send.c @@ -120,7 +120,7 @@ int push_data(struct globals *globals, struct interface *interface, status_end.tx.seqno = htons(seqno);
send_alfred_packet(interface, destination, &status_end, - sizeof(status_end)); + sizeof(status_end)); }
return 0; diff --git a/server.c b/server.c index ab6f4ec..83dfc9b 100644 --- a/server.c +++ b/server.c @@ -72,7 +72,7 @@ static int tx_compare(void *d1, void *d2)
if (memcmp(&txh1->server_addr, &txh2->server_addr, sizeof(txh1->server_addr)) == 0 && - txh1->id == txh2->id) + txh1->id == txh2->id) return 1; else return 0; diff --git a/unix_sock.c b/unix_sock.c index a3affdc..2c862d5 100644 --- a/unix_sock.c +++ b/unix_sock.c @@ -389,7 +389,7 @@ int unix_sock_read(struct globals *globals) case ALFRED_MODESWITCH: ret = unix_sock_modesw(globals, (struct alfred_modeswitch_v0 *)packet, - client_sock); + client_sock); break; case ALFRED_CHANGE_INTERFACE: ret = unix_sock_change_iface(globals,
Signed-off-by: Sven Eckelmann sven@narfation.org --- hash.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/hash.c b/hash.c index 20034d6..13372fa 100644 --- a/hash.c +++ b/hash.c @@ -46,9 +46,9 @@ void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb) for (i = 0; i < hash->size; i++) {
bucket = hash->table[i]; - while (bucket != NULL) { + while (bucket) {
- if (free_cb != NULL) + if (free_cb) free_cb(bucket->data);
last_bucket = bucket; @@ -73,7 +73,7 @@ static int hash_add_bucket(struct hashtable_t *hash, void *data, index = hash->choose(data, hash->size); bucket_it = hash->table[index];
- while (bucket_it != NULL) { + while (bucket_it) { if (check_duplicate && hash->compare(bucket_it->data, data)) return -1; @@ -87,7 +87,7 @@ static int hash_add_bucket(struct hashtable_t *hash, void *data, bucket->next = NULL;
/* and link it */ - if (prev_bucket == NULL) + if (!prev_bucket) hash->table[index] = bucket; else prev_bucket->next = bucket; @@ -117,7 +117,7 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash, { struct hash_it_t *iter;
- if (iter_in == NULL) { + if (!iter_in) { iter = debugMalloc(sizeof(struct hash_it_t), 301); iter->index = -1; iter->bucket = NULL; @@ -128,15 +128,15 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash,
/* sanity checks first (if our bucket got deleted in the last * iteration): */ - if (iter->bucket != NULL) { - if (iter->first_bucket != NULL) { + if (iter->bucket) { + if (iter->first_bucket) {
/* we're on the first element and it got removed after * the last iteration. */ if ((*iter->first_bucket) != iter->bucket) {
/* there are still other elements in the list */ - if ((*iter->first_bucket) != NULL) { + if (*iter->first_bucket) { iter->prev_bucket = NULL; iter->bucket = (*iter->first_bucket); iter->first_bucket = &hash->table[iter->index]; @@ -146,7 +146,7 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash, iter->bucket = NULL; }
- } else if (iter->prev_bucket != NULL) { + } else if (iter->prev_bucket) {
/* we're not on the first element, and the bucket got * removed after the last iteration. The last bucket's @@ -160,8 +160,8 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash, }
/* now as we are sane, select the next one if there is some */ - if (iter->bucket != NULL) { - if (iter->bucket->next != NULL) { + if (iter->bucket) { + if (iter->bucket->next) { iter->prev_bucket = iter->bucket; iter->bucket = iter->bucket->next; iter->first_bucket = NULL; @@ -175,7 +175,7 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash, /* go through the entries of the hash table */ while (iter->index < hash->size) {
- if ((hash->table[iter->index]) == NULL) { + if (!hash->table[iter->index]) { iter->index++; continue; } @@ -244,7 +244,7 @@ void *hash_find(struct hashtable_t *hash, void *keydata) index = hash->choose(keydata , hash->size); bucket = hash->table[index];
- while (bucket != NULL) { + while (bucket) { if (hash->compare(bucket->data, keydata)) return bucket->data;
@@ -265,9 +265,9 @@ void *hash_remove_bucket(struct hashtable_t *hash, struct hash_it_t *hash_it_t) /* save the pointer to the data */ data_save = hash_it_t->bucket->data;
- if (hash_it_t->prev_bucket != NULL) + if (hash_it_t->prev_bucket) hash_it_t->prev_bucket->next = hash_it_t->bucket->next; - else if (hash_it_t->first_bucket != NULL) + else if (hash_it_t->first_bucket) (*hash_it_t->first_bucket) = hash_it_t->bucket->next;
debugFree(hash_it_t->bucket, 1306); @@ -288,7 +288,7 @@ void *hash_remove(struct hashtable_t *hash, void *data) hash_it_t.bucket = hash->table[hash_it_t.index]; hash_it_t.prev_bucket = NULL;
- while (hash_it_t.bucket != NULL) { + while (hash_it_t.bucket) { if (hash->compare(hash_it_t.bucket->data, data)) { struct element_t **first_bucket = NULL;
Signed-off-by: Sven Eckelmann sven@narfation.org --- hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hash.c b/hash.c index 13372fa..4c90a8b 100644 --- a/hash.c +++ b/hash.c @@ -241,7 +241,7 @@ void *hash_find(struct hashtable_t *hash, void *keydata) int index; struct element_t *bucket;
- index = hash->choose(keydata , hash->size); + index = hash->choose(keydata, hash->size); bucket = hash->table[index];
while (bucket) {
Signed-off-by: Sven Eckelmann sven@narfation.org --- hash.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/hash.c b/hash.c index 4c90a8b..f2c8b9c 100644 --- a/hash.c +++ b/hash.c @@ -44,19 +44,16 @@ void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb) int i;
for (i = 0; i < hash->size; i++) { - bucket = hash->table[i]; - while (bucket) {
+ while (bucket) { if (free_cb) free_cb(bucket->data);
last_bucket = bucket; bucket = bucket->next; debugFree(last_bucket, 1301); - } - }
hash_destroy(hash); @@ -130,11 +127,9 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash, * iteration): */ if (iter->bucket) { if (iter->first_bucket) { - /* we're on the first element and it got removed after * the last iteration. */ if ((*iter->first_bucket) != iter->bucket) { - /* there are still other elements in the list */ if (*iter->first_bucket) { iter->prev_bucket = NULL; @@ -145,18 +140,14 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash,
iter->bucket = NULL; } - } else if (iter->prev_bucket) { - /* we're not on the first element, and the bucket got * removed after the last iteration. The last bucket's * next pointer is not pointing to our actual bucket * anymore. Select the next. */ if (iter->prev_bucket->next != iter->bucket) iter->bucket = iter->prev_bucket; - } - }
/* now as we are sane, select the next one if there is some */ @@ -174,7 +165,6 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash, iter->index++; /* go through the entries of the hash table */ while (iter->index < hash->size) { - if (!hash->table[iter->index]) { iter->index++; continue;
Signed-off-by: Sven Eckelmann sven@narfation.org --- alfred.h | 4 +--- batadv_query.c | 4 +--- batadv_query.h | 5 ++--- client.c | 4 +--- debugfs.c | 4 +--- debugfs.h | 4 +--- hash.c | 40 +++++++++++++++++++++++++--------------- hash.h | 32 ++++++++++++++++++++------------ list.h | 4 +--- main.c | 4 +--- netsock.c | 4 +--- packet.h | 4 +--- recv.c | 10 +++++----- send.c | 7 +++---- server.c | 4 +--- unix_sock.c | 4 +--- util.c | 4 +--- 17 files changed, 67 insertions(+), 75 deletions(-)
diff --git a/alfred.h b/alfred.h index f26c80c..2fc8da6 100644 --- a/alfred.h +++ b/alfred.h @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#ifndef SOURCE_VERSION diff --git a/batadv_query.c b/batadv_query.c index c289b80..6a7abea 100644 --- a/batadv_query.c +++ b/batadv_query.c @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#include "batadv_query.h" diff --git a/batadv_query.h b/batadv_query.h index 8991ee9..694ef4c 100644 --- a/batadv_query.h +++ b/batadv_query.h @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2006-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2006-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * @@ -16,8 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */ + #ifndef _BATADV_QUERY_H #define _BATADV_QUERY_H
diff --git a/client.c b/client.c index 22b8439..91a0696 100644 --- a/client.c +++ b/client.c @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#include <ctype.h> diff --git a/debugfs.c b/debugfs.c index fbf992e..a672f55 100644 --- a/debugfs.c +++ b/debugfs.c @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2009 Clark Williams williams@redhat.com +/* Copyright (C) 2009 Clark Williams williams@redhat.com * Copyright (C) 2009 Xiao Guangrong xiaoguangrong@cn.fujitsu.com * * This program is free software; you can redistribute it and/or @@ -15,7 +14,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#include "debugfs.h" diff --git a/debugfs.h b/debugfs.h index b4dc6bb..8fe7eab 100644 --- a/debugfs.h +++ b/debugfs.h @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2009 Clark Williams williams@redhat.com +/* Copyright (C) 2009 Clark Williams williams@redhat.com * Copyright (C) 2009 Xiao Guangrong xiaoguangrong@cn.fujitsu.com * * This program is free software; you can redistribute it and/or @@ -15,7 +14,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#ifndef __DEBUGFS_H__ diff --git a/hash.c b/hash.c index f2c8b9c..c6b34a4 100644 --- a/hash.c +++ b/hash.c @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2006-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2006-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#include "hash.h" @@ -37,7 +35,8 @@ void hash_init(struct hashtable_t *hash)
/* remove the hash structure. if hashdata_free_cb != NULL, * this function will be called to remove the elements inside of the hash. - * if you don't remove the elements, memory might be leaked. */ + * if you don't remove the elements, memory might be leaked. + */ void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb) { struct element_t *bucket, *last_bucket; @@ -60,7 +59,8 @@ void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb) }
/* adds data to the hashtable and reuse bucket. - * returns 0 on success, -1 on error */ + * returns 0 on success, -1 on error + */ static int hash_add_bucket(struct hashtable_t *hash, void *data, struct element_t *bucket, int check_duplicate) { @@ -108,7 +108,8 @@ void hash_iterate_free(struct hash_it_t *iter_in)
/* iterate though the hash. first element is selected with iter_in NULL. * use the returned iterator to access the elements until hash_it_t returns - * NULL. */ + * NULL. + */ struct hash_it_t *hash_iterate(struct hashtable_t *hash, struct hash_it_t *iter_in) { @@ -124,11 +125,13 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash, }
/* sanity checks first (if our bucket got deleted in the last - * iteration): */ + * iteration): + */ if (iter->bucket) { if (iter->first_bucket) { /* we're on the first element and it got removed after - * the last iteration. */ + * the last iteration. + */ if ((*iter->first_bucket) != iter->bucket) { /* there are still other elements in the list */ if (*iter->first_bucket) { @@ -144,7 +147,8 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash, /* we're not on the first element, and the bucket got * removed after the last iteration. The last bucket's * next pointer is not pointing to our actual bucket - * anymore. Select the next. */ + * anymore. Select the next. + */ if (iter->prev_bucket->next != iter->bucket) iter->bucket = iter->prev_bucket; } @@ -160,7 +164,8 @@ struct hash_it_t *hash_iterate(struct hashtable_t *hash, } } /* if not returned yet, we've reached the last one on the index and - * have to search forward */ + * have to search forward + */
iter->index++; /* go through the entries of the hash table */ @@ -225,7 +230,8 @@ int hash_add(struct hashtable_t *hash, void *data) }
/* finds data, based on the key in keydata. returns the found data on success, - * or NULL on error */ + * or NULL on error + */ void *hash_find(struct hashtable_t *hash, void *keydata) { int index; @@ -247,7 +253,8 @@ void *hash_find(struct hashtable_t *hash, void *keydata) /* remove bucket (this might be used in hash_iterate() if you already found * the bucket you want to delete and don't need the overhead to find it again * with hash_remove(). But usually, you don't want to use this function, as it - * fiddles with hash-internals. */ + * fiddles with hash-internals. + */ void *hash_remove_bucket(struct hashtable_t *hash, struct hash_it_t *hash_it_t) { void *data_save; @@ -269,7 +276,8 @@ void *hash_remove_bucket(struct hashtable_t *hash, struct hash_it_t *hash_it_t) /* removes data from hash, if found. returns pointer do data on success, * so you can remove the used structure yourself, or NULL on error . * data could be the structure you use with just the key filled, - * we just need the key for comparing. */ + * we just need the key for comparing. + */ void *hash_remove(struct hashtable_t *hash, void *data) { struct hash_it_t hash_it_t; @@ -298,7 +306,8 @@ void *hash_remove(struct hashtable_t *hash, void *data) }
/* resize the hash, returns the pointer to the new hash or NULL on error. - * removes the old hash on success. */ + * removes the old hash on success. + */ struct hashtable_t *hash_resize(struct hashtable_t *hash, int size) { struct hashtable_t *new_hash; @@ -319,7 +328,8 @@ struct hashtable_t *hash_resize(struct hashtable_t *hash, int size) } } /* remove hash and eventual overflow buckets but not the - * content itself. */ + * content itself. + */ hash_delete(hash, NULL); return new_hash; } diff --git a/hash.h b/hash.h index 6e027bb..09ee8ef 100644 --- a/hash.h +++ b/hash.h @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2006-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2006-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner * @@ -16,8 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */ + #ifndef _BATMAN_HASH_H #define _BATMAN_HASH_H
@@ -39,17 +38,20 @@ struct hash_it_t {
struct hashtable_t { struct element_t **table; /* the hashtable itself, with the - * buckets */ + * buckets + */ int elements; /* number of elements registered */ int size; /* size of hashtable */ hashdata_compare_cb compare; /* callback to a compare function. * should compare 2 element datas for * their keys, return 0 if same and not - * 0 if not same */ + * 0 if not same + */ hashdata_choose_cb choose; /* the hashfunction, should return an * index based on the key in the data * of the first argument and the size - * the second */ + * the second + */ };
/* clears the hash */ @@ -62,13 +64,15 @@ struct hashtable_t *hash_new(int size, hashdata_compare_cb compare, /* remove bucket (this might be used in hash_iterate() if you already found * the bucket you want to delete and don't need the overhead to find it again * with hash_remove(). But usually, you don't want to use this function, as it - * fiddles with hash-internals. */ + * fiddles with hash-internals. + */ void *hash_remove_bucket(struct hashtable_t *hash, struct hash_it_t *hash_it_t);
/* remove the hash structure. if hashdata_free_cb != NULL, * this function will be called to remove the elements inside of the hash. - * if you don't remove the elements, memory might be leaked. */ + * if you don't remove the elements, memory might be leaked. + */ void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb);
/* free only the hashtable and the hash itself. */ @@ -80,15 +84,18 @@ int hash_add(struct hashtable_t *hash, void *data); /* removes data from hash, if found. returns pointer do data on success, * so you can remove the used structure yourself, or NULL on error . * data could be the structure you use with just the key filled, - * we just need the key for comparing. */ + * we just need the key for comparing. + */ void *hash_remove(struct hashtable_t *hash, void *data);
/* finds data, based on the key in keydata. returns the found data on success, - * or NULL on error */ + * or NULL on error + */ void *hash_find(struct hashtable_t *hash, void *keydata);
/* resize the hash, returns the pointer to the new hash or NULL on error. - * removes the old hash on success */ + * removes the old hash on success + */ struct hashtable_t *hash_resize(struct hashtable_t *hash, int size);
/* print the hash table for debugging */ @@ -96,7 +103,8 @@ void hash_debug(struct hashtable_t *hash);
/* iterate though the hash. first element is selected with iter_in NULL. * use the returned iterator to access the elements until hash_it_t - * returns NULL. */ + * returns NULL. + */ struct hash_it_t *hash_iterate(struct hashtable_t *hash, struct hash_it_t *iter_in);
diff --git a/list.h b/list.h index 2ac2c87..a436270 100644 --- a/list.h +++ b/list.h @@ -1,5 +1,4 @@ -/* - * Copyright (C) 1991-2013 linux kernel contributors +/* Copyright (C) 1991-2013 linux kernel contributors * * Linus Torvalds, ... * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#ifndef _LINUX_LIST_H diff --git a/main.c b/main.c index 02553c0..0ee4984 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#include <getopt.h> diff --git a/netsock.c b/netsock.c index 592f3e3..f5fdf48 100644 --- a/netsock.c +++ b/netsock.c @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#include <sys/socket.h> diff --git a/packet.h b/packet.h index 5ecdf39..cbdfc24 100644 --- a/packet.h +++ b/packet.h @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Sven Eckelmann * @@ -14,7 +13,6 @@ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * */
#ifndef _ALFRED_PACKET_H diff --git a/recv.c b/recv.c index 02d96c9..a3b862a 100644 --- a/recv.c +++ b/recv.c @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#include <errno.h> @@ -95,7 +93,8 @@ static int finish_alfred_push_data(struct globals *globals, memcpy(dataset->buf, data->data, data_len);
/* if the sender is also the the source of the dataset, we - * got a first hand dataset. */ + * got a first hand dataset. + */ if (memcmp(&mac, data->source, ETH_ALEN) == 0) dataset->data_source = SOURCE_FIRST_HAND; else @@ -185,7 +184,8 @@ static int process_alfred_push_data(struct globals *globals, head = hash_find(globals->transaction_hash, &search); if (!head) { /* slave must create the transactions to be able to correctly - * wait for it */ + * wait for it + */ if (globals->opmode != OPMODE_MASTER) goto err;
diff --git a/send.c b/send.c index cc55489..911f29e 100644 --- a/send.c +++ b/send.c @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#include <netinet/in.h> @@ -79,7 +77,8 @@ int push_data(struct globals *globals, struct interface *interface, continue;
/* would the packet be too big? send so far aggregated data - * first */ + * first + */ if (total_length + dataset->data.header.length + sizeof(*data) > MAX_PAYLOAD - sizeof(*push)) { tlv_length = total_length; diff --git a/server.c b/server.c index 83dfc9b..8b0cbdc 100644 --- a/server.c +++ b/server.c @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#include <errno.h> diff --git a/unix_sock.c b/unix_sock.c index 2c862d5..1aadeee 100644 --- a/unix_sock.c +++ b/unix_sock.c @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#include <errno.h> diff --git a/util.c b/util.c index 84d4b2d..7c0f7e4 100644 --- a/util.c +++ b/util.c @@ -1,5 +1,4 @@ -/* - * Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: +/* Copyright (C) 2012-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich * @@ -16,7 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA - * */
#include <stddef.h>
On Saturday 14 March 2015 12:42:45 Sven Eckelmann wrote:
Hi,
just some patches which should address some of the checkpatch errors/warnings. It doesn't address things in list.h, debugfs.(c|h) or vis/gpsd.
Kind regards, Sven
Thanks a lot Sven! Applied the whole series except for patch 14, since I don't really like that comment style and don't see much value in making the comments more ugly (for my personal taste).
Thanks, Simon
b.a.t.m.a.n@lists.open-mesh.org