mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Remove util_bug dependency on compat.h
This commit is contained in:
parent
7a93ce8f63
commit
6fc2d53227
@ -493,32 +493,6 @@ tor_strtok_r_impl(char *str, const char *sep, char **lasts)
|
|||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
/** Take a filename and return a pointer to its final element. This
|
|
||||||
* function is called on __FILE__ to fix a MSVC nit where __FILE__
|
|
||||||
* contains the full path to the file. This is bad, because it
|
|
||||||
* confuses users to find the home directory of the person who
|
|
||||||
* compiled the binary in their warning messages.
|
|
||||||
*/
|
|
||||||
const char *
|
|
||||||
tor_fix_source_file(const char *fname)
|
|
||||||
{
|
|
||||||
const char *cp1, *cp2, *r;
|
|
||||||
cp1 = strrchr(fname, '/');
|
|
||||||
cp2 = strrchr(fname, '\\');
|
|
||||||
if (cp1 && cp2) {
|
|
||||||
r = (cp1<cp2)?(cp2+1):(cp1+1);
|
|
||||||
} else if (cp1) {
|
|
||||||
r = cp1+1;
|
|
||||||
} else if (cp2) {
|
|
||||||
r = cp2+1;
|
|
||||||
} else {
|
|
||||||
r = fname;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
#endif /* defined(_WIN32) */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a 16-bit value beginning at <b>cp</b>. Equivalent to
|
* Read a 16-bit value beginning at <b>cp</b>. Equivalent to
|
||||||
* *(uint16_t*)(cp), but will not cause segfaults on platforms that forbid
|
* *(uint16_t*)(cp), but will not cause segfaults on platforms that forbid
|
||||||
|
@ -92,14 +92,6 @@ char *tor_strtok_r_impl(char *str, const char *sep, char **lasts);
|
|||||||
#define tor_strtok_r(str, sep, lasts) tor_strtok_r_impl(str, sep, lasts)
|
#define tor_strtok_r(str, sep, lasts) tor_strtok_r_impl(str, sep, lasts)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define SHORT_FILE__ (tor_fix_source_file(__FILE__))
|
|
||||||
const char *tor_fix_source_file(const char *fname);
|
|
||||||
#else
|
|
||||||
#define SHORT_FILE__ (__FILE__)
|
|
||||||
#define tor_fix_source_file(s) (s)
|
|
||||||
#endif /* defined(_WIN32) */
|
|
||||||
|
|
||||||
/* ===== Time compatibility */
|
/* ===== Time compatibility */
|
||||||
|
|
||||||
struct tm *tor_localtime_r(const time_t *timep, struct tm *result);
|
struct tm *tor_localtime_r(const time_t *timep, struct tm *result);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define TOKEN_BUCKET_PRIVATE
|
#define TOKEN_BUCKET_PRIVATE
|
||||||
|
|
||||||
#include "common/token_bucket.h"
|
#include "common/token_bucket.h"
|
||||||
|
#include "common/compat.h"
|
||||||
#include "common/util_bug.h"
|
#include "common/util_bug.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,4 +253,3 @@ token_bucket_rw_dec(token_bucket_rw_t *bucket,
|
|||||||
flags |= TB_WRITE;
|
flags |= TB_WRITE;
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "lib/container/smartlist.h"
|
#include "lib/container/smartlist.h"
|
||||||
#endif
|
#endif
|
||||||
#include "lib/malloc/util_malloc.h"
|
#include "lib/malloc/util_malloc.h"
|
||||||
|
#include "lib/string/printf.h"
|
||||||
|
|
||||||
#ifdef __COVERITY__
|
#ifdef __COVERITY__
|
||||||
int bug_macro_deadcode_dummy__ = 0;
|
int bug_macro_deadcode_dummy__ = 0;
|
||||||
@ -40,7 +41,7 @@ tor_end_capture_bugs_(void)
|
|||||||
return;
|
return;
|
||||||
SMARTLIST_FOREACH(bug_messages, char *, cp, tor_free(cp));
|
SMARTLIST_FOREACH(bug_messages, char *, cp, tor_free(cp));
|
||||||
smartlist_free(bug_messages);
|
smartlist_free(bug_messages);
|
||||||
bug_messages = NULL;
|
nn bug_messages = NULL;
|
||||||
}
|
}
|
||||||
const smartlist_t *
|
const smartlist_t *
|
||||||
tor_get_captured_bug_log_(void)
|
tor_get_captured_bug_log_(void)
|
||||||
@ -119,3 +120,29 @@ tor_bug_occurred_(const char *fname, unsigned int line,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
/** Take a filename and return a pointer to its final element. This
|
||||||
|
* function is called on __FILE__ to fix a MSVC nit where __FILE__
|
||||||
|
* contains the full path to the file. This is bad, because it
|
||||||
|
* confuses users to find the home directory of the person who
|
||||||
|
* compiled the binary in their warning messages.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
tor_fix_source_file(const char *fname)
|
||||||
|
{
|
||||||
|
const char *cp1, *cp2, *r;
|
||||||
|
cp1 = strrchr(fname, '/');
|
||||||
|
cp2 = strrchr(fname, '\\');
|
||||||
|
if (cp1 && cp2) {
|
||||||
|
r = (cp1<cp2)?(cp2+1):(cp1+1);
|
||||||
|
} else if (cp1) {
|
||||||
|
r = cp1+1;
|
||||||
|
} else if (cp2) {
|
||||||
|
r = cp2+1;
|
||||||
|
} else {
|
||||||
|
r = fname;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
#endif /* defined(_WIN32) */
|
||||||
|
@ -37,8 +37,8 @@
|
|||||||
#define TOR_UTIL_BUG_H
|
#define TOR_UTIL_BUG_H
|
||||||
|
|
||||||
#include "orconfig.h"
|
#include "orconfig.h"
|
||||||
#include <stdlib.h>
|
#include "lib/cc/compat_compiler.h"
|
||||||
#include "common/compat.h"
|
#include "lib/log/torlog.h"
|
||||||
#include "lib/testsupport/testsupport.h"
|
#include "lib/testsupport/testsupport.h"
|
||||||
|
|
||||||
/* Replace assert() with a variant that sends failures to the log before
|
/* Replace assert() with a variant that sends failures to the log before
|
||||||
@ -192,6 +192,14 @@ void tor_bug_occurred_(const char *fname, unsigned int line,
|
|||||||
const char *func, const char *expr,
|
const char *func, const char *expr,
|
||||||
int once);
|
int once);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define SHORT_FILE__ (tor_fix_source_file(__FILE__))
|
||||||
|
const char *tor_fix_source_file(const char *fname);
|
||||||
|
#else
|
||||||
|
#define SHORT_FILE__ (__FILE__)
|
||||||
|
#define tor_fix_source_file(s) (s)
|
||||||
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
#ifdef TOR_UNIT_TESTS
|
#ifdef TOR_UNIT_TESTS
|
||||||
void tor_capture_bugs_(int n);
|
void tor_capture_bugs_(int n);
|
||||||
void tor_end_capture_bugs_(void);
|
void tor_end_capture_bugs_(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user