chg: initialize sockdirfd to -1 instead of AT_FDCWD stable
authorYuya Nishihara <yuya@tcha.org>
Sun, 24 Apr 2016 21:35:30 +0900
branchstable
changeset 29016 94451300f3ec
parent 29015 87d4a6c5567e
child 29017 07be86828e79
chg: initialize sockdirfd to -1 instead of AT_FDCWD As we don't use sockdirfd yet, this is the simplest workaround to compile chg on old Unices where AT_FDCWD does not exist. Foozy pointed out Mac OS X 10.10 is required for AT_FDCWD as well as xxxat() functions.
contrib/chg/chg.c
--- a/contrib/chg/chg.c	Fri Apr 22 13:38:02 2016 -0500
+++ b/contrib/chg/chg.c	Sun Apr 24 21:35:30 2016 +0900
@@ -42,7 +42,7 @@
 static void initcmdserveropts(struct cmdserveropts *opts) {
 	memset(opts, 0, sizeof(struct cmdserveropts));
 	opts->lockfd = -1;
-	opts->sockdirfd = AT_FDCWD;
+	opts->sockdirfd = -1;
 }
 
 static void freecmdserveropts(struct cmdserveropts *opts) {
@@ -50,9 +50,9 @@
 	opts->args = NULL;
 	opts->argsize = 0;
 	assert(opts->lockfd == -1 && "should be closed by unlockcmdserver()");
-	if (opts->sockdirfd != AT_FDCWD) {
+	if (opts->sockdirfd >= 0) {
 		close(opts->sockdirfd);
-		opts->sockdirfd = AT_FDCWD;
+		opts->sockdirfd = -1;
 	}
 }