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>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
d5ab482799
commit
6bb22fea25
@@ -122,7 +122,7 @@ static void kvp_acquire_lock(int pool)
|
|||||||
|
|
||||||
if (fcntl(kvp_file_info[pool].fd, F_SETLKW, &fl) == -1) {
|
if (fcntl(kvp_file_info[pool].fd, F_SETLKW, &fl) == -1) {
|
||||||
syslog(LOG_ERR, "Failed to acquire the lock pool: %d", pool);
|
syslog(LOG_ERR, "Failed to acquire the lock pool: %d", pool);
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ static void kvp_release_lock(int pool)
|
|||||||
if (fcntl(kvp_file_info[pool].fd, F_SETLK, &fl) == -1) {
|
if (fcntl(kvp_file_info[pool].fd, F_SETLK, &fl) == -1) {
|
||||||
perror("fcntl");
|
perror("fcntl");
|
||||||
syslog(LOG_ERR, "Failed to release the lock pool: %d", pool);
|
syslog(LOG_ERR, "Failed to release the lock pool: %d", pool);
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ static void kvp_update_file(int pool)
|
|||||||
if (!filep) {
|
if (!filep) {
|
||||||
kvp_release_lock(pool);
|
kvp_release_lock(pool);
|
||||||
syslog(LOG_ERR, "Failed to open file, pool: %d", pool);
|
syslog(LOG_ERR, "Failed to open file, pool: %d", pool);
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes_written = fwrite(kvp_file_info[pool].records,
|
bytes_written = fwrite(kvp_file_info[pool].records,
|
||||||
@@ -179,7 +179,7 @@ static void kvp_update_mem_state(int pool)
|
|||||||
if (!filep) {
|
if (!filep) {
|
||||||
kvp_release_lock(pool);
|
kvp_release_lock(pool);
|
||||||
syslog(LOG_ERR, "Failed to open file, pool: %d", pool);
|
syslog(LOG_ERR, "Failed to open file, pool: %d", pool);
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
while (!feof(filep)) {
|
while (!feof(filep)) {
|
||||||
readp = &record[records_read];
|
readp = &record[records_read];
|
||||||
@@ -196,7 +196,7 @@ static void kvp_update_mem_state(int pool)
|
|||||||
|
|
||||||
if (record == NULL) {
|
if (record == NULL) {
|
||||||
syslog(LOG_ERR, "malloc failed");
|
syslog(LOG_ERR, "malloc failed");
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,7 @@ static int kvp_file_init(void)
|
|||||||
if (access("/var/opt/hyperv", F_OK)) {
|
if (access("/var/opt/hyperv", F_OK)) {
|
||||||
if (mkdir("/var/opt/hyperv", S_IRUSR | S_IWUSR | S_IROTH)) {
|
if (mkdir("/var/opt/hyperv", S_IRUSR | S_IWUSR | S_IROTH)) {
|
||||||
syslog(LOG_ERR, " Failed to create /var/opt/hyperv");
|
syslog(LOG_ERR, " Failed to create /var/opt/hyperv");
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1358,13 +1358,13 @@ int main(void)
|
|||||||
|
|
||||||
if (kvp_file_init()) {
|
if (kvp_file_init()) {
|
||||||
syslog(LOG_ERR, "Failed to initialize the pools");
|
syslog(LOG_ERR, "Failed to initialize the pools");
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
|
fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
syslog(LOG_ERR, "netlink socket creation failed; error:%d", fd);
|
syslog(LOG_ERR, "netlink socket creation failed; error:%d", fd);
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
addr.nl_family = AF_NETLINK;
|
addr.nl_family = AF_NETLINK;
|
||||||
addr.nl_pad = 0;
|
addr.nl_pad = 0;
|
||||||
@@ -1376,7 +1376,7 @@ int main(void)
|
|||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
syslog(LOG_ERR, "bind failed; error:%d", error);
|
syslog(LOG_ERR, "bind failed; error:%d", error);
|
||||||
close(fd);
|
close(fd);
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
sock_opt = addr.nl_groups;
|
sock_opt = addr.nl_groups;
|
||||||
setsockopt(fd, 270, 1, &sock_opt, sizeof(sock_opt));
|
setsockopt(fd, 270, 1, &sock_opt, sizeof(sock_opt));
|
||||||
@@ -1396,7 +1396,7 @@ int main(void)
|
|||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
syslog(LOG_ERR, "netlink_send failed; error:%d", len);
|
syslog(LOG_ERR, "netlink_send failed; error:%d", len);
|
||||||
close(fd);
|
close(fd);
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
pfd.fd = fd;
|
pfd.fd = fd;
|
||||||
@@ -1608,7 +1608,7 @@ kvp_done:
|
|||||||
len = netlink_send(fd, incoming_cn_msg);
|
len = netlink_send(fd, incoming_cn_msg);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
syslog(LOG_ERR, "net_link send failed; error:%d", len);
|
syslog(LOG_ERR, "net_link send failed; error:%d", len);
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user