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)
{
// tv latency = c2s - s2c;
// 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.;
setDiffToServer(diff);
// tv latency = c2s - s2c;
// 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.;
setDiffToServer(diff);
}

View file

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

View file

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