Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F139443888
D49139.id151508.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D49139.id151508.diff
View Options
diff --git a/usr.sbin/ctld/Makefile b/usr.sbin/ctld/Makefile
--- a/usr.sbin/ctld/Makefile
+++ b/usr.sbin/ctld/Makefile
@@ -4,9 +4,9 @@
.PATH: ${SRCTOP}/contrib/libucl/include
PACKAGE= iscsi
-PROG= ctld
-SRCS= ctld.c conf.c discovery.c isns.c kernel.c
-SRCS+= login.c parse.y token.l y.tab.h uclparse.c
+PROG_CXX= ctld
+SRCS= ctld.cc conf.cc discovery.cc isns.cc kernel.cc
+SRCS+= login.cc parse.y token.l y.tab.h uclparse.cc
CFLAGS+= -I${.CURDIR}
CFLAGS+= -I${SRCTOP}/sys
CFLAGS+= -I${SRCTOP}/sys/cam/ctl
diff --git a/usr.sbin/ctld/conf.h b/usr.sbin/ctld/conf.h
--- a/usr.sbin/ctld/conf.h
+++ b/usr.sbin/ctld/conf.h
@@ -36,6 +36,8 @@
* ctld.
*/
+__BEGIN_DECLS
+
bool auth_group_start(const char *name);
void auth_group_finish(void);
bool auth_group_add_chap(const char *user, const char *secret);
@@ -97,4 +99,6 @@
bool parse_conf(const char *path);
+__END_DECLS
+
#endif /* !__CONF_H__ */
diff --git a/usr.sbin/ctld/conf.c b/usr.sbin/ctld/conf.cc
rename from usr.sbin/ctld/conf.c
rename to usr.sbin/ctld/conf.cc
diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.cc
rename from usr.sbin/ctld/ctld.c
rename to usr.sbin/ctld/ctld.cc
--- a/usr.sbin/ctld/ctld.c
+++ b/usr.sbin/ctld/ctld.cc
@@ -77,6 +77,9 @@
#ifdef ICL_KERNEL_PROXY
.pdu_receive_proxy = pdu_receive_proxy,
.pdu_send_proxy = pdu_send_proxy,
+#else
+ .pdu_receive_proxy = nullptr,
+ .pdu_send_proxy = nullptr,
#endif
.fail = pdu_fail,
};
@@ -95,7 +98,7 @@
{
struct conf *conf;
- conf = calloc(1, sizeof(*conf));
+ conf = reinterpret_cast<struct conf *>(calloc(1, sizeof(*conf)));
if (conf == NULL)
log_err(1, "calloc");
TAILQ_INIT(&conf->conf_luns);
@@ -145,7 +148,7 @@
{
struct auth *auth;
- auth = calloc(1, sizeof(*auth));
+ auth = reinterpret_cast<struct auth *>(calloc(1, sizeof(*auth)));
if (auth == NULL)
log_err(1, "calloc");
auth->a_auth_group = ag;
@@ -303,7 +306,7 @@
{
struct auth_name *an;
- an = calloc(1, sizeof(*an));
+ an = reinterpret_cast<struct auth_name *>(calloc(1, sizeof(*an)));
if (an == NULL)
log_err(1, "calloc");
an->an_auth_group = ag;
@@ -361,7 +364,7 @@
char *net, *mask, *str, *tmp;
int len, dm, m;
- ap = calloc(1, sizeof(*ap));
+ ap = reinterpret_cast<struct auth_portal *>(calloc(1, sizeof(*ap)));
if (ap == NULL)
log_err(1, "calloc");
ap->ap_auth_group = ag;
@@ -494,7 +497,7 @@
}
}
- ag = calloc(1, sizeof(*ag));
+ ag = reinterpret_cast<struct auth_group *>(calloc(1, sizeof(*ag)));
if (ag == NULL)
log_err(1, "calloc");
if (name != NULL)
@@ -547,7 +550,7 @@
{
struct portal *portal;
- portal = calloc(1, sizeof(*portal));
+ portal = reinterpret_cast<struct portal *>(calloc(1, sizeof(*portal)));
if (portal == NULL)
log_err(1, "calloc");
TAILQ_INIT(&portal->p_targets);
@@ -578,7 +581,7 @@
return (NULL);
}
- pg = calloc(1, sizeof(*pg));
+ pg = reinterpret_cast<struct portal_group *>(calloc(1, sizeof(*pg)));
if (pg == NULL)
log_err(1, "calloc");
pg->pg_name = checked_strdup(name);
@@ -711,7 +714,7 @@
{
struct isns *isns;
- isns = calloc(1, sizeof(*isns));
+ isns = reinterpret_cast<struct isns *>(calloc(1, sizeof(*isns)));
if (isns == NULL)
log_err(1, "calloc");
isns->i_conf = conf;
@@ -973,7 +976,7 @@
{
struct pport *pp;
- pp = calloc(1, sizeof(*pp));
+ pp = reinterpret_cast<struct pport *>(calloc(1, sizeof(*pp)));
if (pp == NULL)
log_err(1, "calloc");
pp->pp_kports = kports;
@@ -1032,7 +1035,7 @@
free(name);
return (NULL);
}
- port = calloc(1, sizeof(*port));
+ port = reinterpret_cast<struct port *>(calloc(1, sizeof(*port)));
if (port == NULL)
log_err(1, "calloc");
port->p_conf = conf;
@@ -1077,7 +1080,7 @@
free(name);
return (NULL);
}
- port = calloc(1, sizeof(*port));
+ port = reinterpret_cast<struct port *>(calloc(1, sizeof(*port)));
if (port == NULL)
log_err(1, "calloc");
port->p_conf = conf;
@@ -1106,7 +1109,7 @@
free(name);
return (NULL);
}
- port = calloc(1, sizeof(*port));
+ port = reinterpret_cast<struct port *>(calloc(1, sizeof(*port)));
if (port == NULL)
log_err(1, "calloc");
port->p_conf = conf;
@@ -1187,7 +1190,7 @@
if (valid_iscsi_name(name, log_warnx) == false) {
return (NULL);
}
- targ = calloc(1, sizeof(*targ));
+ targ = reinterpret_cast<struct target *>(calloc(1, sizeof(*targ)));
if (targ == NULL)
log_err(1, "calloc");
targ->t_name = checked_strdup(name);
@@ -1245,7 +1248,7 @@
return (NULL);
}
- lun = calloc(1, sizeof(*lun));
+ lun = reinterpret_cast<struct lun *>(calloc(1, sizeof(*lun)));
if (lun == NULL)
log_err(1, "calloc");
lun->l_conf = conf;
@@ -1365,7 +1368,7 @@
{
struct ctld_connection *conn;
- conn = calloc(1, sizeof(*conn));
+ conn = reinterpret_cast<struct ctld_connection *>(calloc(1, sizeof(*conn)));
if (conn == NULL)
log_err(1, "calloc");
connection_init(&conn->conn, &conn_ops, proxy_mode);
@@ -2254,7 +2257,7 @@
switch (kev.filter) {
case EVFILT_READ:
- portal = kev.udata;
+ portal = reinterpret_cast<struct portal *>(kev.udata);
assert(portal->p_socket == (int)kev.ident);
client_salen = sizeof(client_sa);
diff --git a/usr.sbin/ctld/discovery.c b/usr.sbin/ctld/discovery.cc
rename from usr.sbin/ctld/discovery.c
rename to usr.sbin/ctld/discovery.cc
diff --git a/usr.sbin/ctld/isns.c b/usr.sbin/ctld/isns.cc
rename from usr.sbin/ctld/isns.c
rename to usr.sbin/ctld/isns.cc
--- a/usr.sbin/ctld/isns.c
+++ b/usr.sbin/ctld/isns.cc
@@ -48,14 +48,14 @@
{
struct isns_req *req;
- req = calloc(1, sizeof(struct isns_req));
+ req = reinterpret_cast<struct isns_req *>(calloc(1, sizeof(struct isns_req)));
if (req == NULL) {
log_err(1, "calloc");
return (NULL);
}
req->ir_buflen = sizeof(struct isns_hdr);
req->ir_usedlen = 0;
- req->ir_buf = calloc(1, req->ir_buflen);
+ req->ir_buf = reinterpret_cast<uint8_t *>(calloc(1, req->ir_buflen));
if (req->ir_buf == NULL) {
free(req);
log_err(1, "calloc");
@@ -101,7 +101,7 @@
log_err(1, "realloc");
return (1);
}
- req->ir_buf = newbuf;
+ req->ir_buf = reinterpret_cast<uint8_t *>(newbuf);
req->ir_buflen = newlen;
return (0);
}
diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.cc
rename from usr.sbin/ctld/kernel.c
rename to usr.sbin/ctld/kernel.cc
--- a/usr.sbin/ctld/kernel.c
+++ b/usr.sbin/ctld/kernel.cc
@@ -170,7 +170,7 @@
log_errx(1, "%s: improper lun element nesting",
__func__);
- cur_lun = calloc(1, sizeof(*cur_lun));
+ cur_lun = reinterpret_cast<struct cctl_lun *>(calloc(1, sizeof(*cur_lun)));
if (cur_lun == NULL)
log_err(1, "%s: cannot allocate %zd bytes", __func__,
sizeof(*cur_lun));
@@ -287,7 +287,7 @@
log_errx(1, "%s: improper port element nesting (%s)",
__func__, name);
- cur_port = calloc(1, sizeof(*cur_port));
+ cur_port = reinterpret_cast<struct cctl_port *>(calloc(1, sizeof(*cur_port)));
if (cur_port == NULL)
log_err(1, "%s: cannot allocate %zd bytes", __func__,
sizeof(*cur_port));
@@ -422,7 +422,7 @@
str = NULL;
len = 4096;
retry:
- str = realloc(str, len);
+ str = reinterpret_cast<char *>(realloc(str, len));
if (str == NULL)
log_err(1, "realloc");
@@ -471,7 +471,7 @@
str = NULL;
len = 4096;
retry_port:
- str = realloc(str, len);
+ str = reinterpret_cast<char *>(realloc(str, len));
if (str == NULL)
log_err(1, "realloc");
@@ -691,13 +691,13 @@
req.reqdata.create.device_type = lun->l_device_type;
if (lun->l_serial != NULL) {
- strncpy(req.reqdata.create.serial_num, lun->l_serial,
+ strncpy((char *)req.reqdata.create.serial_num, lun->l_serial,
sizeof(req.reqdata.create.serial_num));
req.reqdata.create.flags |= CTL_LUN_FLAG_SERIAL_NUM;
}
if (lun->l_device_id != NULL) {
- strncpy(req.reqdata.create.device_id, lun->l_device_id,
+ strncpy((char *)req.reqdata.create.device_id, lun->l_device_id,
sizeof(req.reqdata.create.device_id));
req.reqdata.create.flags |= CTL_LUN_FLAG_DEVID;
}
diff --git a/usr.sbin/ctld/login.c b/usr.sbin/ctld/login.cc
rename from usr.sbin/ctld/login.c
rename to usr.sbin/ctld/login.cc
--- a/usr.sbin/ctld/login.c
+++ b/usr.sbin/ctld/login.cc
@@ -47,7 +47,7 @@
#define MAX_DATA_SEGMENT_LENGTH (128 * 1024)
static void login_send_error(struct pdu *request,
- char class, char detail);
+ char error_class, char detail);
static void
kernel_limits(const char *offload, int s, int *max_recv_dsl, int *max_send_dsl,
@@ -230,16 +230,16 @@
}
static void
-login_send_error(struct pdu *request, char class, char detail)
+login_send_error(struct pdu *request, char error_class, char detail)
{
struct pdu *response;
struct iscsi_bhs_login_response *bhslr2;
log_debugx("sending Login Response PDU with failure class 0x%x/0x%x; "
- "see next line for reason", class, detail);
+ "see next line for reason", error_class, detail);
response = login_new_response(request);
bhslr2 = (struct iscsi_bhs_login_response *)response->pdu_bhs;
- bhslr2->bhslr_status_class = class;
+ bhslr2->bhslr_status_class = error_class;
bhslr2->bhslr_status_detail = detail;
pdu_send(response);
diff --git a/usr.sbin/ctld/uclparse.c b/usr.sbin/ctld/uclparse.cc
rename from usr.sbin/ctld/uclparse.c
rename to usr.sbin/ctld/uclparse.cc
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 13, 4:00 AM (7 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26920567
Default Alt Text
D49139.id151508.diff (9 KB)
Attached To
Mode
D49139: ctld: Convert to C++
Attached
Detach File
Event Timeline
Log In to Comment