From f3469070fe899e8e4fd88665386a55bad9f77cd8 Mon Sep 17 00:00:00 2001 From: David Zero Date: Fri, 2 Dec 2016 04:37:23 -0800 Subject: Portability fixes - CFLAG gnu99 was changed to c99. - CXXFLAG c++98 was changed to c++11. - CFLAG -pedantic-errors was added so that non-ISO C now throws errors. - _XOPEN_SOURCE feature test macro added and set to 600 to expose SUSv3 and c99 definitions in modules that required them. - Fixed tests (and bootstrap daemon logging) that were failing due to the altered build flags. - Avoid string suffix misinterpretation; explicit narrowing conversion. - Misc. additions to .gitignore to make sure build artifacts don't wind up in version control. --- testing/DHT_test.c | 2 ++ testing/Messenger_test.c | 2 ++ testing/av_test.c | 2 ++ testing/irc_syncbot.c | 9 +++++---- testing/misc_tools.c | 1 + testing/tox_shell.c | 2 ++ testing/tox_sync.c | 11 ++++++++++- 7 files changed, 24 insertions(+), 5 deletions(-) (limited to 'testing') diff --git a/testing/DHT_test.c b/testing/DHT_test.c index c994f543..6d20d550 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c @@ -27,6 +27,8 @@ * */ +#define _XOPEN_SOURCE 600 + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index 4fd81649..695c50ae 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c @@ -37,6 +37,8 @@ * */ +#define _XOPEN_SOURCE 600 + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/testing/av_test.c b/testing/av_test.c index 7418a15a..aeb661be 100644 --- a/testing/av_test.c +++ b/testing/av_test.c @@ -22,6 +22,8 @@ * -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio */ +#define _XOPEN_SOURCE 600 + #ifdef __cplusplus extern "C" { #endif diff --git a/testing/irc_syncbot.c b/testing/irc_syncbot.c index affc0296..b63b6151 100644 --- a/testing/irc_syncbot.c +++ b/testing/irc_syncbot.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 600 #include #include @@ -34,8 +35,8 @@ static uint16_t port = 6667; static int sock; -#define SERVER_CONNECT "NICK "IRC_NAME"\nUSER "IRC_NAME" 8 * :"IRC_NAME"\n" -#define CHANNEL_JOIN "JOIN "IRC_CHANNEL"\n" +#define SERVER_CONNECT "NICK " IRC_NAME "\nUSER " IRC_NAME " 8 * :" IRC_NAME "\n" +#define CHANNEL_JOIN "JOIN " IRC_CHANNEL "\n" /* In toxcore/network.c */ uint64_t current_time_monotonic(void); @@ -131,8 +132,8 @@ static void copy_groupmessage(Tox *tox, uint32_t groupnumber, uint32_t friendgro uint8_t sendbuf[2048]; uint16_t send_len = 0; - memcpy(sendbuf, "PRIVMSG "IRC_CHANNEL" :", sizeof("PRIVMSG "IRC_CHANNEL" :")); - send_len += sizeof("PRIVMSG "IRC_CHANNEL" :") - 1; + memcpy(sendbuf, "PRIVMSG " IRC_CHANNEL " :", sizeof("PRIVMSG " IRC_CHANNEL " :")); + send_len += sizeof("PRIVMSG " IRC_CHANNEL " :") - 1; memcpy(sendbuf + send_len, name, namelen); send_len += namelen; sendbuf[send_len] = ':'; diff --git a/testing/misc_tools.c b/testing/misc_tools.c index c1292ed8..30c813ca 100644 --- a/testing/misc_tools.c +++ b/testing/misc_tools.c @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef TOX_DEBUG #include diff --git a/testing/tox_shell.c b/testing/tox_shell.c index 18aad9c7..d5de3e67 100644 --- a/testing/tox_shell.c +++ b/testing/tox_shell.c @@ -26,6 +26,8 @@ * */ +#define _XOPEN_SOURCE 600 + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/testing/tox_sync.c b/testing/tox_sync.c index 0c91abfd..6ac3dcf0 100644 --- a/testing/tox_sync.c +++ b/testing/tox_sync.c @@ -28,6 +28,8 @@ * */ +#define _XOPEN_SOURCE 600 + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -42,6 +44,7 @@ #include #include #include +#include #define NUM_FILE_SENDERS 256 typedef struct { @@ -297,6 +300,7 @@ int main(int argc, char *argv[]) memcpy(path, argv[argvoffset + 4], strlen(argv[argvoffset + 4])); DIR *d; struct dirent *dir; + struct stat statbuf; uint8_t notconnected = 1; while (1) { @@ -310,7 +314,12 @@ int main(int argc, char *argv[]) if (d) { while ((dir = readdir(d)) != NULL) { - if (dir->d_type == DT_REG) { + char filepath[strlen(path) + strlen(dir->d_name) + 1]; + memcpy(filepath, path, strlen(path)); + memcpy(filepath + strlen(path), dir->d_name, strlen(dir->d_name) + 1); + stat(filepath, &statbuf); + + if (S_ISREG(statbuf.st_mode)) { char fullpath[1024]; if (path[strlen(path) - 1] == '/') { -- cgit v1.2.3