Skip to content

Commit ce6de47

Browse files
committed
Merge pull request #165 from acv/new-coverity-pass
More coverity fixes
2 parents b80bc0b + 4c35125 commit ce6de47

19 files changed

+72
-96
lines changed

src/auth.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@
4848
#include "client_list.h"
4949
#include "util.h"
5050

51-
/* Defined in clientlist.c */
52-
extern pthread_mutex_t client_list_mutex;
53-
54-
/* Defined in util.c */
55-
extern long served_this_session;
5651

5752
/** Launches a thread that periodically checks if any of the connections has timed out
5853
@param arg Must contain a pointer to a string containing the IP adress of the client to check to check

src/centralserver.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252

5353
#include "simple_http.h"
5454

55-
extern pthread_mutex_t config_mutex;
56-
5755
/** Initiates a transaction with the auth server, either to authenticate or to
5856
* update the traffic counters at the server
5957
@param authresponse Returns the information given by the central server

src/client_list.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* vim: set et sw=4 ts=4 sts=4 : */
12
/********************************************************************\
23
* This program is free software; you can redistribute it and/or *
34
* modify it under the terms of the GNU General Public License as *
@@ -18,9 +19,6 @@
1819
* *
1920
\********************************************************************/
2021

21-
/*
22-
* $Id$
23-
*/
2422
/** @file client_list.c
2523
@brief Client List Functions
2624
@author Copyright (C) 2004 Alexandre Carmel-Veillex <[email protected]>
@@ -44,15 +42,14 @@
4442
#include "conf.h"
4543
#include "client_list.h"
4644

47-
/** Global mutex to protect access to the client list */
48-
extern pthread_mutex_t client_list_mutex;
49-
pthread_mutex_t client_list_mutex = PTHREAD_MUTEX_INITIALIZER;
50-
5145
/** @internal
5246
* Holds a pointer to the first element of the list
5347
*/
5448
static t_client *firstclient = NULL;
5549

50+
/** Global mutex to protect access to the client list */
51+
pthread_mutex_t client_list_mutex = PTHREAD_MUTEX_INITIALIZER;
52+
5653
/** Get a new client struct, not added to the list yet
5754
* @return Pointer to newly created client object not on the list yet.
5855
*/

src/client_list.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* vim: set et sw=4 ts=4 sts=4 : */
12
/********************************************************************\
23
* This program is free software; you can redistribute it and/or *
34
* modify it under the terms of the GNU General Public License as *
@@ -27,6 +28,9 @@
2728
#ifndef _CLIENT_LIST_H_
2829
#define _CLIENT_LIST_H_
2930

31+
/** Global mutex to protect access to the client list */
32+
extern pthread_mutex_t client_list_mutex;
33+
3034
/** Counters struct for a client's bandwidth usage (in bytes)
3135
*/
3236
typedef struct _t_counters {

src/commandline.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* vim: set et sw=4 ts=4 sts=4 : */
12
/********************************************************************\
23
* This program is free software; you can redistribute it and/or *
34
* modify it under the terms of the GNU General Public License as *
@@ -18,7 +19,6 @@
1819
* *
1920
\********************************************************************/
2021

21-
/* $Id$ */
2222
/** @file commandline.c
2323
@brief Command line argument handling
2424
@author Copyright (C) 2004 Philippe April <[email protected]>
@@ -33,28 +33,23 @@
3333
#include "debug.h"
3434
#include "safe.h"
3535
#include "conf.h"
36+
#include "commandline.h"
3637

3738
#include "../config.h"
3839

3940
/*
4041
* Holds an argv that could be passed to exec*() if we restart ourselves
4142
*/
42-
/* Declare variable */
43-
extern char **restartargv;
44-
/* Define variable */
45-
char **restartargv = NULL;
43+
char ** restartargv = NULL;
4644

47-
static void usage(void);
48-
49-
void parse_commandline(int argc, char **argv);
50-
51-
/*
45+
/**
5246
* A flag to denote whether we were restarted via a parent wifidog, or started normally
5347
* 0 means normally, otherwise it will be populated by the PID of the parent
5448
*/
55-
extern pid_t restart_orig_pid;
5649
pid_t restart_orig_pid = 0;
5750

51+
static void usage(void);
52+
5853
/** @internal
5954
* @brief Print usage
6055
*
@@ -97,7 +92,6 @@ parse_commandline(int argc, char **argv)
9792
restartargv[i++] = safe_strdup(argv[0]);
9893

9994
while (-1 != (c = getopt(argc, argv, "c:hfd:sw:vx:i:"))) {
100-
10195
skiponrestart = 0;
10296

10397
switch (c) {
@@ -185,5 +179,4 @@ parse_commandline(int argc, char **argv)
185179
restartargv[i++] = NULL;
186180
restartargv[i++] = NULL;
187181
restartargv[i++] = NULL;
188-
189182
}

src/commandline.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* vim: set et sw=4 ts=4 sts=4 : */
12
/********************************************************************\
23
* This program is free software; you can redistribute it and/or *
34
* modify it under the terms of the GNU General Public License as *
@@ -27,6 +28,17 @@
2728
#ifndef _COMMANDLINE_H_
2829
#define _COMMANDLINE_H_
2930

31+
/*
32+
* Holds an argv that could be passed to exec*() if we restart ourselves
33+
*/
34+
extern char **restartargv;
35+
36+
/**
37+
* A flag to denote whether we were restarted via a parent wifidog, or started normally
38+
* 0 means normally, otherwise it will be populated by the PID of the parent
39+
*/
40+
extern pid_t restart_orig_pid;
41+
3042
/** @brief Parses the command line and set the config accordingly */
3143
void parse_commandline(int, char **);
3244

src/conf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ static s_config config;
5555
/**
5656
* Mutex for the configuration file, used by the auth_servers related
5757
* functions. */
58-
extern pthread_mutex_t config_mutex;
5958
pthread_mutex_t config_mutex = PTHREAD_MUTEX_INITIALIZER;
6059

6160
/** @internal

src/conf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@
8383
#define FWRULESET_LOCKED_USERS "locked-users"
8484
/*@}*/
8585

86+
/**
87+
* Mutex for the configuration file, used by the auth_servers related
88+
* functions. */
89+
extern pthread_mutex_t config_mutex;
90+
8691
/**
8792
* Information about the authentication server
8893
*/

src/firewall.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* vim: set et sw=4 ts=4 sts=4 : */
12
/********************************************************************\
23
* This program is free software; you can redistribute it and/or *
34
* modify it under the terms of the GNU General Public License as *
@@ -18,9 +19,6 @@
1819
* *
1920
\********************************************************************/
2021

21-
/*
22-
* $Id$
23-
*/
2422
/** @internal
2523
@file firewall.c
2624
@brief Firewall update functions
@@ -64,13 +62,7 @@
6462
#include "auth.h"
6563
#include "centralserver.h"
6664
#include "client_list.h"
67-
68-
extern pthread_mutex_t client_list_mutex;
69-
70-
/* from commandline.c */
71-
extern pid_t restart_orig_pid;
72-
73-
65+
#include "commandline.h"
7466

7567
/**
7668
* Allow a client access through the firewall by adding a rule in the firewall to MARK the user's packets with the proper

src/fw_iptables.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ static int iptables_do_command(const char *format, ...);
5252
static char *iptables_compile(const char *, const char *, const t_firewall_rule *);
5353
static void iptables_load_ruleset(const char *, const char *, const char *);
5454

55-
extern pthread_mutex_t client_list_mutex;
56-
extern pthread_mutex_t config_mutex;
57-
5855
/**
5956
Used to supress the error output of the firewall during destruction */
6057
static int fw_quiet = 0;

0 commit comments

Comments
 (0)