mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
Workaround for brain-damaged __FILE__ handling on MSVC: keep Nick's name out
of the warning messages. svn:r3199
This commit is contained in:
parent
64195e380d
commit
32978afa54
@ -113,6 +113,29 @@ int tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 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 warrning messages.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
_tor_fix_source_file(const char *fname)
|
||||||
|
{
|
||||||
|
const char *cp1, *cp2;
|
||||||
|
cp1 = strrchr(fname, '/');
|
||||||
|
cp2 = strrchr(fname, '\\');
|
||||||
|
if (cp1 && cp2) {
|
||||||
|
return (cp1<cp2)?(cp2+1):(cp1+1);
|
||||||
|
} else if (cp1) {
|
||||||
|
return cp1+1;
|
||||||
|
} else if (cp2) {
|
||||||
|
return cp2+2;
|
||||||
|
} else {
|
||||||
|
return fname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef UNALIGNED_INT_ACCESS_OK
|
#ifndef UNALIGNED_INT_ACCESS_OK
|
||||||
/**
|
/**
|
||||||
* Read a 16-bit value beginning at <b>cp</b>. Equivalent to
|
* Read a 16-bit value beginning at <b>cp</b>. Equivalent to
|
||||||
|
@ -86,6 +86,9 @@ int tor_vsnprintf(char *str, size_t size, const char *format, va_list args);
|
|||||||
#define TOR_ISXDIGIT(c) isxdigit((int)(unsigned char)(c))
|
#define TOR_ISXDIGIT(c) isxdigit((int)(unsigned char)(c))
|
||||||
#define TOR_ISDIGIT(c) isdigit((int)(unsigned char)(c))
|
#define TOR_ISDIGIT(c) isdigit((int)(unsigned char)(c))
|
||||||
|
|
||||||
|
#define _SHORT_FILE_ (_tor_fix_source_file(__FILE__))
|
||||||
|
const char *_tor_fix_source_file(const char *fname);
|
||||||
|
|
||||||
/* ===== Time compatibility */
|
/* ===== Time compatibility */
|
||||||
#if !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_STRUCT_TIMEVAL_TV_SEC)
|
#if !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_STRUCT_TIMEVAL_TV_SEC)
|
||||||
struct timeval {
|
struct timeval {
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "compat.h"
|
||||||
|
|
||||||
#define STMT_BEGIN do {
|
#define STMT_BEGIN do {
|
||||||
#define STMT_END } while (0)
|
#define STMT_END } while (0)
|
||||||
@ -29,7 +30,7 @@ extern int have_failed;
|
|||||||
STMT_BEGIN \
|
STMT_BEGIN \
|
||||||
have_failed = 1; \
|
have_failed = 1; \
|
||||||
printf("\nFile %s: line %d (%s): assertion failed.", \
|
printf("\nFile %s: line %d (%s): assertion failed.", \
|
||||||
__FILE__, \
|
_SHORT_FILE_, \
|
||||||
__LINE__, \
|
__LINE__, \
|
||||||
PRETTY_FUNCTION); \
|
PRETTY_FUNCTION); \
|
||||||
return; \
|
return; \
|
||||||
@ -40,7 +41,7 @@ extern int have_failed;
|
|||||||
if (expr) { printf("."); fflush(stdout); } else { \
|
if (expr) { printf("."); fflush(stdout); } else { \
|
||||||
have_failed = 1; \
|
have_failed = 1; \
|
||||||
printf("\nFile %s: line %d (%s): assertion failed: (%s)\n", \
|
printf("\nFile %s: line %d (%s): assertion failed: (%s)\n", \
|
||||||
__FILE__, \
|
_SHORT_FILE_, \
|
||||||
__LINE__, \
|
__LINE__, \
|
||||||
PRETTY_FUNCTION, \
|
PRETTY_FUNCTION, \
|
||||||
#expr); \
|
#expr); \
|
||||||
@ -54,7 +55,7 @@ extern int have_failed;
|
|||||||
have_failed = 1; \
|
have_failed = 1; \
|
||||||
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
|
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
|
||||||
" (%ld != %ld)\n", \
|
" (%ld != %ld)\n", \
|
||||||
__FILE__, \
|
_SHORT_FILE_, \
|
||||||
__LINE__, \
|
__LINE__, \
|
||||||
PRETTY_FUNCTION, \
|
PRETTY_FUNCTION, \
|
||||||
#expr1, #expr2, \
|
#expr1, #expr2, \
|
||||||
@ -69,7 +70,7 @@ extern int have_failed;
|
|||||||
have_failed = 1; \
|
have_failed = 1; \
|
||||||
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
|
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
|
||||||
" (%ld == %ld)\n", \
|
" (%ld == %ld)\n", \
|
||||||
__FILE__, \
|
_SHORT_FILE_, \
|
||||||
__LINE__, \
|
__LINE__, \
|
||||||
PRETTY_FUNCTION, \
|
PRETTY_FUNCTION, \
|
||||||
#expr1, #expr2, \
|
#expr1, #expr2, \
|
||||||
@ -84,7 +85,7 @@ extern int have_failed;
|
|||||||
have_failed = 1; \
|
have_failed = 1; \
|
||||||
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
|
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\
|
||||||
" (\"%s\" != \"%s\")\n", \
|
" (\"%s\" != \"%s\")\n", \
|
||||||
__FILE__, \
|
_SHORT_FILE_, \
|
||||||
__LINE__, \
|
__LINE__, \
|
||||||
PRETTY_FUNCTION, \
|
PRETTY_FUNCTION, \
|
||||||
#expr1, #expr2, \
|
#expr1, #expr2, \
|
||||||
@ -99,7 +100,7 @@ extern int have_failed;
|
|||||||
have_failed = 1; \
|
have_failed = 1; \
|
||||||
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
|
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n"\
|
||||||
" (\"%s\" == \"%s\")\n", \
|
" (\"%s\" == \"%s\")\n", \
|
||||||
__FILE__, \
|
_SHORT_FILE_, \
|
||||||
__LINE__, \
|
__LINE__, \
|
||||||
PRETTY_FUNCTION, \
|
PRETTY_FUNCTION, \
|
||||||
#expr1, #expr2, \
|
#expr1, #expr2, \
|
||||||
@ -113,7 +114,7 @@ extern int have_failed;
|
|||||||
if (!memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else {\
|
if (!memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else {\
|
||||||
have_failed = 1; \
|
have_failed = 1; \
|
||||||
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n", \
|
printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n", \
|
||||||
__FILE__, \
|
_SHORT_FILE_, \
|
||||||
__LINE__, \
|
__LINE__, \
|
||||||
PRETTY_FUNCTION, \
|
PRETTY_FUNCTION, \
|
||||||
#expr1, #expr2); \
|
#expr1, #expr2); \
|
||||||
@ -126,7 +127,7 @@ extern int have_failed;
|
|||||||
if (memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else {\
|
if (memcmp(v1,v2,(len))) { printf("."); fflush(stdout); } else {\
|
||||||
have_failed = 1; \
|
have_failed = 1; \
|
||||||
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n", \
|
printf("\nFile %s: line %d (%s): Assertion failed: (%s!=%s)\n", \
|
||||||
__FILE__, \
|
_SHORT_FILE_, \
|
||||||
__LINE__, \
|
__LINE__, \
|
||||||
PRETTY_FUNCTION, \
|
PRETTY_FUNCTION, \
|
||||||
#expr1, #expr2); \
|
#expr1, #expr2); \
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
#include "../common/crypto.h"
|
#include "../common/crypto.h"
|
||||||
|
#include "../common/compat.h"
|
||||||
|
|
||||||
/* Opaque structure to hold a TLS connection. */
|
/* Opaque structure to hold a TLS connection. */
|
||||||
typedef struct tor_tls_st tor_tls;
|
typedef struct tor_tls_st tor_tls;
|
||||||
@ -42,7 +43,7 @@ unsigned long tor_tls_get_n_bytes_written(tor_tls *tls);
|
|||||||
|
|
||||||
/* Log and abort if there are unhandled TLS errors in OpenSSL's error stack.
|
/* Log and abort if there are unhandled TLS errors in OpenSSL's error stack.
|
||||||
*/
|
*/
|
||||||
#define assert_no_tls_errors() _assert_no_tls_errors(__FILE__,__LINE__)
|
#define assert_no_tls_errors() _assert_no_tls_errors(_SHORT_FILE_,__LINE__)
|
||||||
|
|
||||||
void _assert_no_tls_errors(const char *fname, int line);
|
void _assert_no_tls_errors(const char *fname, int line);
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "orconfig.h"
|
#include "orconfig.h"
|
||||||
#include "torint.h"
|
#include "torint.h"
|
||||||
|
#include "compat.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef HAVE_SYS_TIME_H
|
#ifdef HAVE_SYS_TIME_H
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -38,7 +39,7 @@
|
|||||||
#define tor_assert(expr) do { \
|
#define tor_assert(expr) do { \
|
||||||
if (!(expr)) { \
|
if (!(expr)) { \
|
||||||
log(LOG_ERR, "%s:%d: %s: Assertion %s failed; aborting.", \
|
log(LOG_ERR, "%s:%d: %s: Assertion %s failed; aborting.", \
|
||||||
__FILE__, __LINE__, __FUNCTION__, #expr); \
|
_SHORT_FILE_, __LINE__, __FUNCTION__, #expr); \
|
||||||
assert(expr); /* write to console too. */ \
|
assert(expr); /* write to console too. */ \
|
||||||
abort(); /* unreached */ \
|
abort(); /* unreached */ \
|
||||||
} } while (0)
|
} } while (0)
|
||||||
|
10
src/or/or.h
10
src/or/or.h
@ -1070,9 +1070,10 @@ int _circuit_mark_for_close(circuit_t *circ);
|
|||||||
do { \
|
do { \
|
||||||
if (_circuit_mark_for_close(c)<0) { \
|
if (_circuit_mark_for_close(c)<0) { \
|
||||||
log(LOG_WARN,"Duplicate call to circuit_mark_for_close at %s:%d (first at %s:%d)", \
|
log(LOG_WARN,"Duplicate call to circuit_mark_for_close at %s:%d (first at %s:%d)", \
|
||||||
__FILE__,__LINE__,c->marked_for_close_file,c->marked_for_close); \
|
_SHORT_FILE_,__LINE__, \
|
||||||
|
c->marked_for_close_file,c->marked_for_close); \
|
||||||
} else { \
|
} else { \
|
||||||
c->marked_for_close_file = __FILE__; \
|
c->marked_for_close_file = _SHORT_FILE_; \
|
||||||
c->marked_for_close = __LINE__; \
|
c->marked_for_close = __LINE__; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -1154,9 +1155,10 @@ int _connection_mark_for_close(connection_t *conn);
|
|||||||
do { \
|
do { \
|
||||||
if (_connection_mark_for_close(c)<0) { \
|
if (_connection_mark_for_close(c)<0) { \
|
||||||
log(LOG_WARN,"Duplicate call to connection_mark_for_close at %s:%d (first at %s:%d)", \
|
log(LOG_WARN,"Duplicate call to connection_mark_for_close at %s:%d (first at %s:%d)", \
|
||||||
__FILE__,__LINE__,c->marked_for_close_file,c->marked_for_close); \
|
_SHORT_FILE_,__LINE__, \
|
||||||
|
c->marked_for_close_file,c->marked_for_close); \
|
||||||
} else { \
|
} else { \
|
||||||
c->marked_for_close_file = __FILE__; \
|
c->marked_for_close_file = _SHORT_FILE_; \
|
||||||
c->marked_for_close = __LINE__; \
|
c->marked_for_close = __LINE__; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
Loading…
Reference in New Issue
Block a user