Skip to content

Commit 5c40fe4

Browse files
committed
Avoid some clang warnings in C++ code.
1 parent a8b84b5 commit 5c40fe4

File tree

16 files changed

+45
-26
lines changed

16 files changed

+45
-26
lines changed

cpp/src/ToxAv/ToxAv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#define PREFIX toxav
1717
#endif
1818

19+
void reference_symbols_av ();
20+
1921
namespace av
2022
{
2123
namespace proto = im::tox::tox4j::av::proto;

cpp/src/ToxAv/lifecycle.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,11 @@ toxav_new_unique (Tox *tox, TOXAV_ERR_NEW *error)
105105
}
106106

107107

108-
static void
108+
static NORETURN void
109109
toxav_finalize ()
110110
{
111-
assert (!"This function is only here for register_funcs and should never be called.");
111+
fprintf (stderr, "This function is only here for register_funcs and should never be called.");
112+
abort ();
112113
}
113114

114115

cpp/src/ToxCore/ToxCore.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@ template<> char const *exn_prefix<Tox>() { return ""; }
99

1010
#include "generated/impls.h"
1111

12+
#define TOX_DEFAULT_PROXY_PORT 8080
13+
#define TOX_DEFAULT_TCP_PORT 0
14+
#define TOX_DEFAULT_START_PORT 33445
15+
#define TOX_DEFAULT_END_PORT (TOX_DEFAULT_START_PORT + 100)
16+
#include "generated/constants.h"
17+
1218
void
1319
reference_symbols_core ()
1420
{
1521
int tox_finalize; // For Java only.
1622

23+
checkToxCoreConstants();
1724
#define JAVA_METHOD_REF(NAME) unused (JAVA_METHOD_NAME (NAME));
1825
#define CXX_FUNCTION_REF(NAME) unused (NAME);
1926
#include "generated/natives.h"
2027
#undef CXX_FUNCTION_REF
2128
#undef JAVA_METHOD_REF
2229
}
23-
24-
#define TOX_DEFAULT_PROXY_PORT 8080
25-
#define TOX_DEFAULT_TCP_PORT 0
26-
#define TOX_DEFAULT_START_PORT 33445
27-
#define TOX_DEFAULT_END_PORT (TOX_DEFAULT_START_PORT + 100)
28-
#include "generated/constants.h"

cpp/src/ToxCore/ToxCore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#define PREFIX tox
1717
#endif
1818

19+
void reference_symbols_core ();
20+
1921
namespace core
2022
{
2123
namespace proto = im::tox::tox4j::core::proto;

cpp/src/ToxCore/generated/constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// im.tox.tox4j.core.ToxCoreConstants$
2-
void
2+
static void
33
checkToxCoreConstants ()
44
{
55
static_assert (TOX_ADDRESS_SIZE == 38, "Java constant out of sync with C");

cpp/src/ToxCore/lifecycle.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,11 @@ tox_new_unique (Tox_Options const *options, TOX_ERR_NEW *error)
212212
}
213213

214214

215-
static void
215+
static NORETURN void
216216
tox_finalize ()
217217
{
218-
assert (!"This function is only here for register_funcs and should never be called.");
218+
fprintf (stderr, "This function is only here for register_funcs and should never be called.");
219+
abort ();
219220
}
220221

221222

cpp/src/ToxCrypto/ToxCrypto.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ template<> char const *exn_prefix<ToxCrypto>() { return ""; }
1717
void
1818
reference_symbols_crypto ()
1919
{
20+
checkToxCryptoConstants ();
2021
#define JAVA_METHOD_REF(NAME) unused (JAVA_METHOD_NAME (NAME));
2122
#define CXX_FUNCTION_REF(NAME) unused (NAME);
2223
#include "generated/natives.h"

cpp/src/ToxCrypto/ToxCrypto.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212
#define PREFIX tox
1313

1414

15+
void reference_symbols_crypto ();
16+
1517
struct ToxCrypto;

cpp/src/ToxCrypto/generated/constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// im.tox.tox4j.crypto.ToxCryptoConstants$
2-
void
2+
static void
33
checkToxCryptoConstants ()
44
{
55
static_assert (TOX_PASS_BOX_ZERO_BYTES == 16, "Java constant out of sync with C");

cpp/src/tox4j/Tox4j.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
#include "util/to_bytes.h"
1212

1313

14+
#if defined(__GNUC__)
15+
#define NORETURN __attribute__((__noreturn__))
16+
#else
17+
#define NORETURN
18+
#endif
19+
20+
1421
#define JAVA_METHOD_NAME(NAME) \
1522
PP_CAT(Java_im_tox_tox4j_impl_jni_, PP_CAT(CLASS, PP_CAT(Jni_, NAME)))
1623

0 commit comments

Comments
 (0)