summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2020-02-08 09:22:46 +0200
committerToomas Soome <tsoome@me.com>2020-04-02 09:53:35 +0300
commit476d5ff73c235a63ab06a9852e510910a3ce1793 (patch)
tree31d858c3be567d568e986b6ff8bb071a2eb205ed
parent86e38daa32bf0ca85f79384da2d3e43bf87f328b (diff)
downloadillumos-joyent-476d5ff73c235a63ab06a9852e510910a3ce1793.tar.gz
12432 vntsd: NULL pointer errors
Reviewed by: Gergő Doma <domag02@gmail.com> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/cmd/vntsd/console.c34
-rw-r--r--usr/src/cmd/vntsd/read.c3
-rw-r--r--usr/src/cmd/vntsd/vntsd.c2
-rw-r--r--usr/src/cmd/vntsd/vntsdvcc.c8
-rw-r--r--usr/src/cmd/vntsd/write.c3
5 files changed, 22 insertions, 28 deletions
diff --git a/usr/src/cmd/vntsd/console.c b/usr/src/cmd/vntsd/console.c
index 6cd29c5f7c..543f117e8d 100644
--- a/usr/src/cmd/vntsd/console.c
+++ b/usr/src/cmd/vntsd/console.c
@@ -22,7 +22,6 @@
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Listen thread creates a console thread whenever there is a tcp client
@@ -95,8 +94,7 @@ write_connect_msg(vntsd_client_t *clientp, char *group_name,
}
if ((rv = vntsd_write_line(clientp,
- gettext("Press ~? for control options .."))) !=
- VNTSD_SUCCESS) {
+ gettext("Press ~? for control options .."))) != VNTSD_SUCCESS) {
return (rv);
}
@@ -112,7 +110,7 @@ create_write_thread(vntsd_cons_t *consp)
/* create write thread for the console */
(void) mutex_lock(&consp->lock);
if (thr_create(NULL, 0, (thr_func_t)vntsd_write_thread,
- (void *)consp, NULL, &consp->wr_tid)) {
+ (void *)consp, 0, &consp->wr_tid)) {
DERR(stderr, "t@%d create_rd_wr_thread@%d: "
"create write thread failed\n",
@@ -156,7 +154,7 @@ list_all_domains(vntsd_group_t *groupp, vntsd_client_t *clientp)
(void) mutex_lock(&groupp->lock);
if (vntsd_que_find(groupp->conspq, (compare_func_t)display_domain_name,
- &(clientp->sockfd)) != NULL) {
+ &(clientp->sockfd)) != NULL) {
rv = VNTSD_ERR_WRITE_CLIENT;
}
@@ -172,8 +170,8 @@ display_help(vntsd_client_t *clientp)
int rv = VNTSD_SUCCESS;
char *bufp;
- if ((rv = vntsd_write_client(clientp, vntsd_eol, VNTSD_EOL_LEN))
- != VNTSD_SUCCESS) {
+ rv = vntsd_write_client(clientp, vntsd_eol, VNTSD_EOL_LEN);
+ if (rv != VNTSD_SUCCESS) {
return (rv);
}
@@ -208,7 +206,7 @@ display_help(vntsd_client_t *clientp)
*/
bufp = gettext("c{id}, n{name} -- connect to a console of domain {id}"
- " or domain {name}");
+ " or domain {name}");
if ((rv = vntsd_write_line(clientp, bufp)) != VNTSD_SUCCESS) {
return (rv);
@@ -234,7 +232,7 @@ name_to_cons_no(vntsd_group_t *groupp, char *name)
vntsd_cons_t *consp;
consp = (vntsd_cons_t *)vntsd_que_find(groupp->conspq,
- (compare_func_t)cons_by_name, name);
+ (compare_func_t)cons_by_name, name);
if (consp == NULL) {
return (-1);
@@ -280,7 +278,7 @@ select_cons(vntsd_group_t *groupp, vntsd_cons_t **consp,
case 'c':
/* c{id} or c {id} */
if (isspace(buf[i])) {
- continue;
+ continue;
}
if (!isdigit(buf[i])) {
@@ -293,7 +291,7 @@ select_cons(vntsd_group_t *groupp, vntsd_cons_t **consp,
case 'n':
/* n{name) or n {name} */
if (isspace(buf[i])) {
- continue;
+ continue;
}
buf[n-1] = 0;
@@ -318,7 +316,7 @@ select_cons(vntsd_group_t *groupp, vntsd_cons_t **consp,
(void) mutex_lock(&groupp->lock);
*consp = (vntsd_cons_t *)vntsd_que_find(groupp->conspq,
- (compare_func_t)vntsd_cons_by_consno, &cons_no);
+ (compare_func_t)vntsd_cons_by_consno, &cons_no);
if (*consp == NULL) {
/* during console selection, the console has been deleted */
@@ -487,13 +485,13 @@ read_cmd(vntsd_client_t *clientp, char *prompt, char *cmd)
clientp->status |= VNTSD_CLIENT_DISABLE_DAEMON_CMD;
(void) mutex_unlock(&clientp->lock);
- if ((rv = vntsd_write_client(clientp, vntsd_eol, VNTSD_EOL_LEN))
- != VNTSD_SUCCESS) {
+ rv = vntsd_write_client(clientp, vntsd_eol, VNTSD_EOL_LEN);
+ if (rv != VNTSD_SUCCESS) {
return (rv);
}
- if ((rv = vntsd_write_client(clientp, prompt, strlen(prompt)))
- != VNTSD_SUCCESS) {
+ rv = vntsd_write_client(clientp, prompt, strlen(prompt));
+ if (rv != VNTSD_SUCCESS) {
return (rv);
}
@@ -778,11 +776,11 @@ vntsd_console_thread(vntsd_thr_arg_t *argp)
}
if (snprintf(prompt, sizeof (prompt),
- "%s-vnts-%s: h, l, c{id}, n{name}, q:",
+ "%s-vnts-%s: h, l, c{id}, n{name}, q:",
buf, groupp->group_name) >= sizeof (prompt)) {
/* long prompt doesn't fit, use short one */
(void) snprintf(prompt, sizeof (prompt),
- "vnts: h, l, c{id}, n{name}, q:");
+ "vnts: h, l, c{id}, n{name}, q:");
}
diff --git a/usr/src/cmd/vntsd/read.c b/usr/src/cmd/vntsd/read.c
index d3cc711603..75b377cd02 100644
--- a/usr/src/cmd/vntsd/read.c
+++ b/usr/src/cmd/vntsd/read.c
@@ -18,7 +18,6 @@
*
* CDDL HEADER END
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
@@ -284,5 +283,5 @@ vntsd_read(vntsd_client_t *clientp)
}
/*NOTREACHED*/
- return (NULL);
+ return (0);
}
diff --git a/usr/src/cmd/vntsd/vntsd.c b/usr/src/cmd/vntsd/vntsd.c
index d32d88f3f3..9fd07d2b69 100644
--- a/usr/src/cmd/vntsd/vntsd.c
+++ b/usr/src/cmd/vntsd/vntsd.c
@@ -358,7 +358,7 @@ main(int argc, char ** argv)
"descriptor limit.");
(void) enable_extended_FILE_stdio(-1, -1);
- vntsdp = calloc(sizeof (vntsd_t), 1);
+ vntsdp = calloc(1, sizeof (vntsd_t));
if (vntsdp == NULL) {
vntsd_log(VNTSD_ERR_NO_MEM, "main:vntsdp");
exit(1);
diff --git a/usr/src/cmd/vntsd/vntsdvcc.c b/usr/src/cmd/vntsd/vntsdvcc.c
index ff93bc36cc..4274c0ff7d 100644
--- a/usr/src/cmd/vntsd/vntsdvcc.c
+++ b/usr/src/cmd/vntsd/vntsdvcc.c
@@ -22,7 +22,6 @@
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Configuration and setup interface to vcc driver.
@@ -206,7 +205,7 @@ vntsd_delete_cons(vntsd_t *vntsdp)
(void) mutex_lock(&groupp->vntsd->lock);
(void) vntsd_que_rm(&groupp->vntsd->grouppq,
- groupp);
+ groupp);
(void) mutex_unlock(&groupp->vntsd->lock);
/* clean up the group */
@@ -459,7 +458,7 @@ alloc_cons_with_group(vntsd_t *vntsdp, vcc_console_t *consp,
/* intialize console */
if (alloc_cons(groupp, consp) == NULL) {
/* no memory */
- if (new_groupp != NULL) {
+ if (*new_groupp != NULL) {
/* clean up new group */
free_group(groupp);
}
@@ -488,8 +487,7 @@ create_listen_thread(vntsd_group_t *groupp)
D1(stderr, "t@%d create_listen:%lld\n", thr_self(), groupp->tcp_port);
if ((rv = thr_create(NULL, 0, (thr_func_t)vntsd_listen_thread,
- (void *)groupp, THR_DETACHED, &groupp->listen_tid))
- != 0) {
+ (void *)groupp, THR_DETACHED, &groupp->listen_tid)) != 0) {
(void) (void) snprintf(err_msg, sizeof (err_msg),
"Can not create listen thread for"
"group %s tcp %llx\n", groupp->group_name,
diff --git a/usr/src/cmd/vntsd/write.c b/usr/src/cmd/vntsd/write.c
index 9110056c11..a56c60e7dd 100644
--- a/usr/src/cmd/vntsd/write.c
+++ b/usr/src/cmd/vntsd/write.c
@@ -22,7 +22,6 @@
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
/*
* write thread - read from vcc console and write to tcp client. There are one
@@ -198,7 +197,7 @@ write_one_client(vntsd_client_t *clientp, write_buf_t *write_buf)
(void) mutex_lock(&clientp->lock);
clientp->status |= VNTSD_CLIENT_IO_ERR;
assert(clientp->cons);
- (void) thr_kill(clientp->cons_tid, NULL);
+ (void) thr_kill(clientp->cons_tid, 0);
(void) mutex_unlock(&clientp->lock);
}
return (B_FALSE);