Silence some warnings on GCC 4.9

This commit is contained in:
Eelco Dolstra 2014-12-12 17:14:28 +01:00 committed by Ludovic Courtès
parent 159b7103a7
commit b499d2efbf
3 changed files with 12 additions and 6 deletions

View File

@ -2009,9 +2009,11 @@ void DerivationGoal::runChild()
/* Set the hostname etc. to fixed values. */
char hostname[] = "localhost";
sethostname(hostname, sizeof(hostname));
if (sethostname(hostname, sizeof(hostname)) == -1)
throw SysError("cannot set host name");
char domainname[] = "(none)"; // kernel default
setdomainname(domainname, sizeof(domainname));
if (setdomainname(domainname, sizeof(domainname)) == -1)
throw SysError("cannot set domain name");
/* Make all filesystems private. This is necessary
because subtrees may have been mounted as "shared"

View File

@ -109,7 +109,7 @@ void RemoteStore::connectToDaemon()
applications... */
AutoCloseFD fdPrevDir = open(".", O_RDONLY);
if (fdPrevDir == -1) throw SysError("couldn't open current directory");
chdir(dirOf(socketPath).c_str());
if (chdir(dirOf(socketPath).c_str()) == -1) throw SysError("couldn't change current directory");
Path socketPathRel = "./" + baseNameOf(socketPath);
struct sockaddr_un addr;

View File

@ -793,6 +793,9 @@ bool matchUser(const string & user, const string & group, const Strings & users)
static void daemonLoop()
{
if (chdir("/") == -1)
throw SysError("cannot change current directory");
/* Get rid of children automatically; don't let them become
zombies. */
setSigChldAction(true);
@ -821,7 +824,8 @@ static void daemonLoop()
/* Urgh, sockaddr_un allows path names of only 108 characters.
So chdir to the socket directory so that we can pass a
relative path name. */
chdir(dirOf(socketPath).c_str());
if (chdir(dirOf(socketPath).c_str()) == -1)
throw SysError("cannot change current directory");
Path socketPathRel = "./" + baseNameOf(socketPath);
struct sockaddr_un addr;
@ -841,7 +845,8 @@ static void daemonLoop()
if (res == -1)
throw SysError(format("cannot bind to socket `%1%'") % socketPath);
chdir("/"); /* back to the root */
if (chdir("/") == -1) /* back to the root */
throw SysError("cannot change current directory");
if (listen(fdSocket, 5) == -1)
throw SysError(format("cannot listen on socket `%1%'") % socketPath);
@ -945,7 +950,6 @@ void run(Strings args)
if (arg == "--daemon") /* ignored for backwards compatibility */;
}
chdir("/");
daemonLoop();
}