alfred: checkpatch cleanup
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
PATCH 1/14 alfred: Add spaces around operators
--- batadv_query.c | 6 +++--- hash.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
batadv_query.c +3 -3
@@ -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;
hash.c +1 -1
@@ -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 );
Signature · 1 line
2.1.4
PATCH 2/14 alfred: checkpatch - else is not generally useful after a break or return
In reply to Sven Eckelmann--- batadv_query.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
batadv_query.c +3 -3
@@ -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 ;
Signature · 1 line
2.1.4
PATCH 3/14 alfred: Reduce number of lines with more than 80 chars
In reply to Sven Eckelmann--- batadv_query.h | 3 ++- client.c | 4 +++- hash.c | 13 +++++++------ 3 files changed, 12 insertions(+), 8 deletions(-)
batadv_query.h +2 -1
@@ -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);
client.c +3 -1
@@ -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 ;
hash.c +7 -6
@@ -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); }
Signature · 1 line
2.1.4
PATCH 4/14 alfred: Remove double semicolons
In reply to Sven Eckelmann--- client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
client.c +1 -1
@@ -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)
Signature · 1 line
2.1.4
PATCH 5/14 alfred: Remove trailing whitespace at end of line
In reply to Sven Eckelmann--- README | 6 +++--- hash.h | 2 +- list.h | 2 +- send.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
README +3 -3
@@ -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 -------------------------------
hash.h +1 -1
@@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2006-2015 B.A.T.M.A.N. contributors: * * Simon Wunderlich, Marek Lindner
list.h +1 -1
@@ -1,6 +1,6 @@/* * Copyright (C) 1991-2013 linux kernel contributors -* +* * Linus Torvalds, ... * * This program is free software; you can redistribute it and/or
send.c +1 -1
@@ -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);
Signature · 1 line
2.1.4
PATCH 6/14 alfred: Remove spaces before tabs
In reply to Sven Eckelmann--- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
main.c +2 -2
@@ -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'},
Signature · 1 line
2.1.4
PATCH 7/14 alfred: Remove else and break after return
In reply to Sven Eckelmann--- hash.c | 3 +-- main.c | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-)
hash.c +1 -2
@@ -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 ) {
main.c +0 -5
@@ -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 ;
Signature · 1 line
2.1.4
PATCH 8/14 alfred: Remove multiple blank lines
In reply to Sven Eckelmann--- 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(-)
hash.c +0 -1
@@ -19,7 +19,6 @@* */ -#include "hash.h" #include <stdlib.h> #include <stdio.h>
hash.h +0 -2
@@ -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 *);
packet.h +0 -1
@@ -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
recv.c +0 -4
@@ -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 ];
send.c +0 -1
@@ -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 ;
server.c +0 -4
@@ -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 ; } - -
unix_sock.c +0 -2
@@ -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) {
Signature · 1 line
2.1.4
PATCH 9/14 alfred: Fix typo transfered -> transferred
In reply to Sven Eckelmann--- packet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
packet.h +1 -1
@@ -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 */
Signature · 1 line
2.1.4
PATCH 10/14 alfred: Fix alignment of multi-line statements
In reply to Sven Eckelmann--- hash.h | 2 +- send.c | 2 +- server.c | 2 +- unix_sock.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
hash.h +1 -1
@@ -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
send.c +1 -1
@@ -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 ;
server.c +1 -1
@@ -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 ;
unix_sock.c +1 -1
@@ -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,
Signature · 1 line
2.1.4
PATCH 11/14 alfred: Simplify comparison of pointer with NULL
In reply to Sven Eckelmann--- hash.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
hash.c +16 -16
@@ -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 ;
Signature · 1 line
2.1.4
PATCH 12/14 alfred: Remove spaces before ','
In reply to Sven Eckelmann--- hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hash.c +1 -1
@@ -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) {
Signature · 1 line
2.1.4
PATCH 13/14 alfred: Remove empty lines after '{'
In reply to Sven Eckelmann--- hash.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
hash.c +1 -11
@@ -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 ;
Signature · 1 line
2.1.4
PATCH 14/14 alfred: Use Linux-net style comment blocks
In reply to Sven Eckelmann--- 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(-)
alfred.h +1 -3
@@ -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
batadv_query.c +1 -3
@@ -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"
batadv_query.h +2 -3
@@ -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
client.c +1 -3
@@ -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>
debugfs.c +1 -3
@@ -1,5 +1,4 @@ -/* -* Copyright (C) 2009 Clark Williams <[email protected]> +/* Copyright (C) 2009 Clark Williams <[email protected]> * Copyright (C) 2009 Xiao Guangrong <[email protected]> * * 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"
debugfs.h +1 -3
@@ -1,5 +1,4 @@ -/* -* Copyright (C) 2009 Clark Williams <[email protected]> +/* Copyright (C) 2009 Clark Williams <[email protected]> * Copyright (C) 2009 Xiao Guangrong <[email protected]> * * 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__
hash.c +25 -15
@@ -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; }
hash.h +20 -12
@@ -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);
list.h +1 -3
@@ -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
main.c +1 -3
@@ -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>
netsock.c +1 -3
@@ -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>
packet.h +1 -3
@@ -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
recv.c +5 -5
@@ -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;
send.c +3 -4
@@ -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;
server.c +1 -3
@@ -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>
unix_sock.c +1 -3
@@ -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>
util.c +1 -3
@@ -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>
Signature · 1 line
2.1.4
Quoted 8 lines · 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