small code clean-ups

This commit is contained in:
badaix 2018-04-25 14:13:43 +02:00
parent 3ff49c81b2
commit 9259257490
3 changed files with 15 additions and 15 deletions

View file

@ -28,10 +28,10 @@ TimeProvider::TimeProvider() : diffToServer_(0)
void TimeProvider::setDiff(const tv& c2s, const tv& s2c) void TimeProvider::setDiff(const tv& c2s, const tv& s2c)
{ {
// tv latency = c2s - s2c; // tv latency = c2s - s2c;
// double diff = (latency.sec * 1000. + latency.usec / 1000.) / 2.; // double diff = (latency.sec * 1000. + latency.usec / 1000.) / 2.;
double diff = ((double)c2s.sec / 2. - (double)s2c.sec / 2.) * 1000. + ((double)c2s.usec / 2. - (double)s2c.usec / 2.) / 1000.; double diff = ((double)c2s.sec / 2. - (double)s2c.sec / 2.) * 1000. + ((double)c2s.usec / 2. - (double)s2c.usec / 2.) / 1000.;
setDiffToServer(diff); setDiffToServer(diff);
} }

View file

@ -68,9 +68,9 @@ void Daemon::daemonize()
uid_t user_uid = (uid_t)-1; uid_t user_uid = (uid_t)-1;
gid_t user_gid = (gid_t)-1; gid_t user_gid = (gid_t)-1;
std::string user_name; std::string user_name;
#ifdef FREEBSD //#ifdef FREEBSD
bool had_group = false; // bool had_group = false;
#endif //#endif
if (!user_.empty()) if (!user_.empty())
{ {
@ -90,9 +90,9 @@ void Daemon::daemonize()
if (grp == nullptr) if (grp == nullptr)
throw SnapException("no such group \"" + group_ + "\""); throw SnapException("no such group \"" + group_ + "\"");
user_gid = grp->gr_gid; user_gid = grp->gr_gid;
#ifdef FREEBSD //#ifdef FREEBSD
had_group = true; // had_group = true;
#endif //#endif
} }
if (chown(pidfile_.c_str(), user_uid, user_gid) == -1) if (chown(pidfile_.c_str(), user_uid, user_gid) == -1)

View file

@ -27,10 +27,10 @@ using namespace std;
static string hex2str(string input) static string hex2str(string input)
{ {
typedef unsigned char byte; typedef unsigned char byte;
unsigned long x = strtoul(input.c_str(), 0, 16); unsigned long x = strtoul(input.c_str(), 0, 16);
byte a[] = {byte(x >> 24), byte(x >> 16), byte(x >> 8), byte(x), 0}; byte a[] = {byte(x >> 24), byte(x >> 16), byte(x >> 8), byte(x), 0};
return string((char *)a); return string((char *)a);
} }
/* /*
@ -45,7 +45,7 @@ AirplayStream::AirplayStream(PcmListener* pcmListener, const StreamUri& uri) : P
{ {
logStderr_ = true; logStderr_ = true;
pipePath_ = "/tmp/shairmeta." + cpt::to_string(getpid()); pipePath_ = "/tmp/shairmeta." + cpt::to_string(getpid());
//cout << "Pipe [" << pipePath_ << "]\n"; //cout << "Pipe [" << pipePath_ << "]\n";
// XXX: Check if pipe exists, delete or throw error // XXX: Check if pipe exists, delete or throw error