aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2012-09-05 17:37:36 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-10 19:43:05 -0400
commit6bb22fea25624ab593eee376fa5fb82d1b13f45a (patch)
treee7befe25e0264de757770c2065a2821b4422f4e5 /tools
parentd5ab482799e7c4c4b7c0aa67e8710dce28115d03 (diff)
tools/hv: Fix exit() error code
Linux native exit codes are 8-bit unsigned values. exit(-1) results in an exit code of 255, which is usually reserved for shells reporting 'command not found'. Use the portable value EXIT_FAILURE. (Not that this matters much for a daemon.) Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/hv/hv_kvp_daemon.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 4514fb41da5e..01b3ca583baf 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -122,7 +122,7 @@ static void kvp_acquire_lock(int pool)
122 122
123 if (fcntl(kvp_file_info[pool].fd, F_SETLKW, &fl) == -1) { 123 if (fcntl(kvp_file_info[pool].fd, F_SETLKW, &fl) == -1) {
124 syslog(LOG_ERR, "Failed to acquire the lock pool: %d", pool); 124 syslog(LOG_ERR, "Failed to acquire the lock pool: %d", pool);
125 exit(-1); 125 exit(EXIT_FAILURE);
126 } 126 }
127} 127}
128 128
@@ -134,7 +134,7 @@ static void kvp_release_lock(int pool)
134 if (fcntl(kvp_file_info[pool].fd, F_SETLK, &fl) == -1) { 134 if (fcntl(kvp_file_info[pool].fd, F_SETLK, &fl) == -1) {
135 perror("fcntl"); 135 perror("fcntl");
136 syslog(LOG_ERR, "Failed to release the lock pool: %d", pool); 136 syslog(LOG_ERR, "Failed to release the lock pool: %d", pool);
137 exit(-1); 137 exit(EXIT_FAILURE);
138 } 138 }
139} 139}
140 140
@@ -153,7 +153,7 @@ static void kvp_update_file(int pool)
153 if (!filep) { 153 if (!filep) {
154 kvp_release_lock(pool); 154 kvp_release_lock(pool);
155 syslog(LOG_ERR, "Failed to open file, pool: %d", pool); 155 syslog(LOG_ERR, "Failed to open file, pool: %d", pool);
156 exit(-1); 156 exit(EXIT_FAILURE);
157 } 157 }
158 158
159 bytes_written = fwrite(kvp_file_info[pool].records, 159 bytes_written = fwrite(kvp_file_info[pool].records,
@@ -179,7 +179,7 @@ static void kvp_update_mem_state(int pool)
179 if (!filep) { 179 if (!filep) {
180 kvp_release_lock(pool); 180 kvp_release_lock(pool);
181 syslog(LOG_ERR, "Failed to open file, pool: %d", pool); 181 syslog(LOG_ERR, "Failed to open file, pool: %d", pool);
182 exit(-1); 182 exit(EXIT_FAILURE);
183 } 183 }
184 while (!feof(filep)) { 184 while (!feof(filep)) {
185 readp = &record[records_read]; 185 readp = &record[records_read];
@@ -196,7 +196,7 @@ static void kvp_update_mem_state(int pool)
196 196
197 if (record == NULL) { 197 if (record == NULL) {
198 syslog(LOG_ERR, "malloc failed"); 198 syslog(LOG_ERR, "malloc failed");
199 exit(-1); 199 exit(EXIT_FAILURE);
200 } 200 }
201 continue; 201 continue;
202 } 202 }
@@ -225,7 +225,7 @@ static int kvp_file_init(void)
225 if (access("/var/opt/hyperv", F_OK)) { 225 if (access("/var/opt/hyperv", F_OK)) {
226 if (mkdir("/var/opt/hyperv", S_IRUSR | S_IWUSR | S_IROTH)) { 226 if (mkdir("/var/opt/hyperv", S_IRUSR | S_IWUSR | S_IROTH)) {
227 syslog(LOG_ERR, " Failed to create /var/opt/hyperv"); 227 syslog(LOG_ERR, " Failed to create /var/opt/hyperv");
228 exit(-1); 228 exit(EXIT_FAILURE);
229 } 229 }
230 } 230 }
231 231
@@ -1358,13 +1358,13 @@ int main(void)
1358 1358
1359 if (kvp_file_init()) { 1359 if (kvp_file_init()) {
1360 syslog(LOG_ERR, "Failed to initialize the pools"); 1360 syslog(LOG_ERR, "Failed to initialize the pools");
1361 exit(-1); 1361 exit(EXIT_FAILURE);
1362 } 1362 }
1363 1363
1364 fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR); 1364 fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
1365 if (fd < 0) { 1365 if (fd < 0) {
1366 syslog(LOG_ERR, "netlink socket creation failed; error:%d", fd); 1366 syslog(LOG_ERR, "netlink socket creation failed; error:%d", fd);
1367 exit(-1); 1367 exit(EXIT_FAILURE);
1368 } 1368 }
1369 addr.nl_family = AF_NETLINK; 1369 addr.nl_family = AF_NETLINK;
1370 addr.nl_pad = 0; 1370 addr.nl_pad = 0;
@@ -1376,7 +1376,7 @@ int main(void)
1376 if (error < 0) { 1376 if (error < 0) {
1377 syslog(LOG_ERR, "bind failed; error:%d", error); 1377 syslog(LOG_ERR, "bind failed; error:%d", error);
1378 close(fd); 1378 close(fd);
1379 exit(-1); 1379 exit(EXIT_FAILURE);
1380 } 1380 }
1381 sock_opt = addr.nl_groups; 1381 sock_opt = addr.nl_groups;
1382 setsockopt(fd, 270, 1, &sock_opt, sizeof(sock_opt)); 1382 setsockopt(fd, 270, 1, &sock_opt, sizeof(sock_opt));
@@ -1396,7 +1396,7 @@ int main(void)
1396 if (len < 0) { 1396 if (len < 0) {
1397 syslog(LOG_ERR, "netlink_send failed; error:%d", len); 1397 syslog(LOG_ERR, "netlink_send failed; error:%d", len);
1398 close(fd); 1398 close(fd);
1399 exit(-1); 1399 exit(EXIT_FAILURE);
1400 } 1400 }
1401 1401
1402 pfd.fd = fd; 1402 pfd.fd = fd;
@@ -1608,7 +1608,7 @@ kvp_done:
1608 len = netlink_send(fd, incoming_cn_msg); 1608 len = netlink_send(fd, incoming_cn_msg);
1609 if (len < 0) { 1609 if (len < 0) {
1610 syslog(LOG_ERR, "net_link send failed; error:%d", len); 1610 syslog(LOG_ERR, "net_link send failed; error:%d", len);
1611 exit(-1); 1611 exit(EXIT_FAILURE);
1612 } 1612 }
1613 } 1613 }
1614 1614