Skip to content

Commit

Permalink
Merge 065b74f into cd52e13
Browse files Browse the repository at this point in the history
  • Loading branch information
nmathewson committed Mar 12, 2019
2 parents cd52e13 + 065b74f commit dc48ddb
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changes/ticket29756
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
o Minor features (developer tools):
- Add a script to check that each header has a well-formed and unique
guard marco. Closes ticket 29756.
32 changes: 32 additions & 0 deletions scripts/maint/checkSpace.pl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ sub msg {

our %basenames = ();

our %guardnames = ();

for my $fn (@ARGV) {
open(F, "$fn");
my $lastnil = 0;
Expand All @@ -31,6 +33,10 @@ sub msg {
} else {
$basenames{$basename} = $fn;
}
my $isheader = ($fn =~ /\.h/);
my $seenguard = 0;
my $guardname = "<none>";

while (<F>) {
## Warn about windows-style newlines.
# (We insist on lines that end with a single LF character, not
Expand Down Expand Up @@ -112,6 +118,23 @@ sub msg {
next;
}
}

if ($isheader) {
if ($seenguard == 0) {
if (/ifndef\s+(\S+)/) {
++$seenguard;
$guardname = $1;
}
} elsif ($seenguard == 1) {
if (/^\#define (\S+)/) {
++$seenguard;
if ($1 ne $guardname) {
msg "GUARD:$fn:$.: Header guard macro mismatch.\n";
}
}
}
}

if (m!/\*.*?\*/!) {
s!\s*/\*.*?\*/!!;
} elsif (m!/\*!) {
Expand Down Expand Up @@ -201,6 +224,15 @@ sub msg {
}
}
}
if ($isheader && $C) {
if ($seenguard < 2) {
msg "$fn:No #ifndef/#define header guard pair found.\n";
} elsif ($guardnames{$guardname}) {
msg "$fn:Guard macro $guardname also used in $guardnames{$guardname}\n";
} else {
$guardnames{$guardname} = $fn;
}
}
close(F);
}

Expand Down
1 change: 1 addition & 0 deletions src/feature/control/btrack_orconn_cevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
**/

#ifndef TOR_BTRACK_ORCONN_CEVENT_H
#define TOR_BTRACK_ORCONN_CEVENT_H

#include "feature/control/btrack_orconn.h"

Expand Down
1 change: 1 addition & 0 deletions src/feature/control/btrack_orconn_maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
**/

#ifndef TOR_BTRACK_ORCONN_MAPS_H
#define TOR_BTRACK_ORCONN_MAPS_H

void bto_delete(uint64_t);
bt_orconn_t *bto_find_or_new(uint64_t, uint64_t);
Expand Down
4 changes: 4 additions & 0 deletions src/feature/hs/hs_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
* \brief Header file for hs_stats.c
**/

#ifndef TOR_HS_STATS_H
#define TOR_HS_STATS_H

void hs_stats_note_introduce2_cell(int is_hsv3);
uint32_t hs_stats_get_n_introduce2_v3_cells(void);
uint32_t hs_stats_get_n_introduce2_v2_cells(void);
void hs_stats_note_service_rendezvous_launch(void);
uint32_t hs_stats_get_n_rendezvous_launches(void);

#endif
2 changes: 1 addition & 1 deletion src/lib/log/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
**/

#ifndef TOR_TORLOG_H
#define TOR_TORLOG_H

#include <stdarg.h>
#include "lib/cc/torint.h"
Expand Down Expand Up @@ -278,5 +279,4 @@ MOCK_DECL(STATIC void, logv, (int severity, log_domain_mask_t domain,
va_list ap) CHECK_PRINTF(5,0));
#endif

# define TOR_TORLOG_H
#endif /* !defined(TOR_TORLOG_H) */
4 changes: 4 additions & 0 deletions src/test/test_connection.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* Copyright (c) 2014-2019, The Tor Project, Inc. */
/* See LICENSE for licensing information */

#ifndef TOR_TEST_CONNECTION_H
#define TOR_TEST_CONNECTION_H

/** Some constants used by test_connection and helpers */
#define TEST_CONN_FAMILY (AF_INET)
#define TEST_CONN_ADDRESS "127.0.0.1"
Expand All @@ -11,3 +14,4 @@
void test_conn_lookup_addr_helper(const char *address,
int family, tor_addr_t *addr);

#endif
4 changes: 4 additions & 0 deletions src/test/test_dir_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Copyright (c) 2007-2019, The Tor Project, Inc. */
/* See LICENSE for licensing information */

#ifndef TOR_TEST_DIR_COMMON_H
#define TOR_TEST_DIR_COMMON_H

#include "core/or/or.h"
#include "feature/nodelist/networkstatus.h"

Expand Down Expand Up @@ -49,3 +52,4 @@ int dir_common_construct_vote_3(networkstatus_t **vote,
networkstatus_t **vote_out, int *n_vrs, time_t now,
int clear_rl);

#endif

0 comments on commit dc48ddb

Please sign in to comment.