[R] Fix warnings from R check --as-cran (#6374)
* Remove exit and printf. * Fix warnings.
This commit is contained in:
@@ -69,10 +69,6 @@ inline bool StringToBool(const char* s) {
|
||||
return CompareStringsCaseInsensitive(s, "true") == 0 || atoi(s) != 0;
|
||||
}
|
||||
|
||||
inline void HandlePrint(const char *msg) {
|
||||
printf("%s", msg);
|
||||
}
|
||||
|
||||
/*! \brief printf, prints messages to the console */
|
||||
inline void Printf(const char *fmt, ...) {
|
||||
std::string msg(kPrintBuffer, '\0');
|
||||
@@ -80,7 +76,7 @@ inline void Printf(const char *fmt, ...) {
|
||||
va_start(args, fmt);
|
||||
vsnprintf(&msg[0], kPrintBuffer, fmt, args);
|
||||
va_end(args);
|
||||
HandlePrint(msg.c_str());
|
||||
LOG(CONSOLE) << msg;
|
||||
}
|
||||
|
||||
/*! \brief assert a condition is true, use this to handle debug information */
|
||||
|
||||
@@ -104,9 +104,7 @@ bool AllreduceBase::Init(int argc, char* argv[]) {
|
||||
}
|
||||
}
|
||||
if (dmlc_role != "worker") {
|
||||
fprintf(stderr, "Rabit Module currently only work with dmlc worker"\
|
||||
", quit this program by exit 0\n");
|
||||
exit(0);
|
||||
LOG(FATAL) << "Rabit Module currently only work with dmlc worker";
|
||||
}
|
||||
|
||||
// clear the setting before start reconnection
|
||||
@@ -236,10 +234,10 @@ utils::TCPSocket AllreduceBase::ConnectTracker() const {
|
||||
do {
|
||||
if (!tracker.Connect(utils::SockAddr(tracker_uri.c_str(), tracker_port))) {
|
||||
if (++retry >= connect_retry) {
|
||||
fprintf(stderr, "connect to (failed): [%s]\n", tracker_uri.c_str());
|
||||
LOG(WARNING) << "Connect to (failed): [" << tracker_uri << "]\n";
|
||||
utils::Socket::Error("Connect");
|
||||
} else {
|
||||
fprintf(stderr, "retry connect to ip(retry time %d): [%s]\n", retry, tracker_uri.c_str());
|
||||
LOG(WARNING) << "Retry connect to ip(retry time " << retry << "): [" << tracker_uri << "]\n";
|
||||
#if defined(_MSC_VER) || defined (__MINGW32__)
|
||||
Sleep(retry << 1);
|
||||
#else
|
||||
@@ -295,10 +293,11 @@ bool AllreduceBase::ReConnectLinks(const char *cmd) {
|
||||
"must keep rank to same if the node already have one");
|
||||
rank = newrank;
|
||||
|
||||
// tracker got overwhelemed and not able to assign correct rank
|
||||
if (rank == -1) exit(-1);
|
||||
if (rank == -1) {
|
||||
LOG(FATAL) << "tracker got overwhelemed and not able to assign correct rank";
|
||||
}
|
||||
|
||||
fprintf(stdout, "task %s got new rank %d\n", task_id.c_str(), rank);
|
||||
LOG(CONSOLE) << "task " << task_id << " got new rank " << rank;
|
||||
|
||||
Assert(tracker.RecvAll(&num_neighbors, sizeof(num_neighbors)) == \
|
||||
sizeof(num_neighbors), "ReConnectLink failure 4");
|
||||
@@ -424,7 +423,7 @@ bool AllreduceBase::ReConnectLinks(const char *cmd) {
|
||||
setsockopt(all_link.sock, IPPROTO_TCP,
|
||||
TCP_NODELAY, reinterpret_cast<void *>(&tcpNoDelay), sizeof(tcpNoDelay));
|
||||
#else
|
||||
fprintf(stderr, "tcp no delay is not implemented on non unix platforms\n");
|
||||
LOG(WARNING) << "tcp no delay is not implemented on non unix platforms";
|
||||
#endif
|
||||
}
|
||||
if (tree_neighbors.count(all_link.rank) != 0) {
|
||||
@@ -444,7 +443,7 @@ bool AllreduceBase::ReConnectLinks(const char *cmd) {
|
||||
"cannot find next ring in the link");
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
fprintf(stderr, "failed in ReconnectLink %s\n", e.what());
|
||||
LOG(WARNING) << "failed in ReconnectLink " << e.what();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,8 +226,7 @@ class AllreduceBase : public IEngine {
|
||||
*/
|
||||
inline void ReportStatus() const {
|
||||
if (hadoop_mode != 0) {
|
||||
fprintf(stderr, "reporter:status:Rabit Phase[%03d] Operation %03d\n",
|
||||
version_number, seq_counter);
|
||||
LOG(CONSOLE) << "reporter:status:Rabit Phase[" << version_number << "] Operation " << seq_counter << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user