From nobody Tue Jan 27 18:44:21 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4f0vT22dZ6z6QG1k for ; Tue, 27 Jan 2026 18:44:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f0vT205b5z3rRP for ; Tue, 27 Jan 2026 18:44:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1769539462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oC3He2eTC12M9uhCat/SxNdtHD28/JoibwVZ/il2IxQ=; b=i8Del58t0oBu+dbjYodse45QQxnkR4DroFcharu3087ByIg4JCeNoPoAoVpwXPpASxITGP w4l9ouecP8Mm5WvHDFA7sZ7LcnLnc/9fIQjX1E/lKEXsH2YPIwmA38aqUSG8ZDKwyOmiCg 0yfVjR1CQrODElYHHxmEAlwljPYYUM3Uj2gUyTwaFCK0APF7xz6HaBRnPMaeZThHGJh/fq 94untNYL+rVjvtxoQDG2SqymQpCZvHT4129f+zqas3uQcUfpEdHlom7/f0fLGyQ1mMmNk2 +yCdK3E1I+h/6cB7S3JKB/cmskwT1NLBeGO4qerRSV2hTmSd8nQgHIzWeCVYfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1769539462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oC3He2eTC12M9uhCat/SxNdtHD28/JoibwVZ/il2IxQ=; b=DEHwRvOyAnCh89SHo9omBg7wbNXXRJ6czC6iVhOTJ1BkZNHA5L8CmJfEEBZESzRRRNfyM/ H4qalV94gqkglIw2hBtvNXP1TaVnJ0Cn/Voh904hkZWp1mk7qt0s+/3nECov5XQu2NLRLv AzZBe2ElPmFKFmxiT0J2y65zhgc9l7DV0AnCIFHlknQsbv+uu4wcTVmiwLaw9SanuanU/e R1WMMJu+I4qH8bf9YmLxC/fjNyuK/C87oQpy1zI+s1/Jpjaa/+fVtCTLFkU4VUuVqeTzzA bKfgMzcPoLz2f066hxt8CqJc9U5vPHIUQxGLwl13hOEGxpT3AGRnDZU3w/43dQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1769539462; a=rsa-sha256; cv=none; b=LLu85CF5FAaKsoiLyC3bp/l7AmdoBwEMdbmECoS3/dLE3inz3yWMB5iExsEHZoMlY6Jmgy SLh+02/N9qcKwdXUXZpv5bumRIGjb8yx+eM81URdpMIpwUJ6+oIWHLdytjP8yPd1FUq9YI hVMA/I0B5zLs8lVKknDRDobFASBD1EixOzSIZmuzYd332uybzDiZ9zJquXNkx3WnBcukAw /zp+keJlH7v/eHettNduieuYCzZut4c921Gyoq4SvlieZzZTnzp4qIeSqE4WyaP/27IAbj VhMj1dFAvyzPmaKMVmdnzZ1fV2w94TFxZ/ClPYH9Gh35VCfJrxYLcjcP85JnHg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f0vT16XNfz3dY for ; Tue, 27 Jan 2026 18:44:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id f8ec by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 27 Jan 2026 18:44:21 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 6bb9cb02c84b - stable/14 - ctld: Convert to C++ List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 6bb9cb02c84b6d64124ae47dd158b6c0bd32f844 Auto-Submitted: auto-generated Date: Tue, 27 Jan 2026 18:44:21 +0000 Message-Id: <69790785.f8ec.69c70fa3@gitrepo.freebsd.org> The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=6bb9cb02c84b6d64124ae47dd158b6c0bd32f844 commit 6bb9cb02c84b6d64124ae47dd158b6c0bd32f844 Author: John Baldwin AuthorDate: 2025-04-02 18:41:35 +0000 Commit: John Baldwin CommitDate: 2026-01-27 18:15:57 +0000 ctld: Convert to C++ This is the minimal set of changes need to compile as C++ so git can handle the rename correctly. Reviewed by: asomers Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D49139 (cherry picked from commit 839d0755fea8ef761698b50fa5f293546ae832a8) --- usr.sbin/ctld/Makefile | 6 ++--- usr.sbin/ctld/{conf.c => conf.cc} | 0 usr.sbin/ctld/conf.h | 4 ++++ usr.sbin/ctld/{ctld.c => ctld.cc} | 35 ++++++++++++++++------------- usr.sbin/ctld/{discovery.c => discovery.cc} | 0 usr.sbin/ctld/{isns.c => isns.cc} | 6 ++--- usr.sbin/ctld/{kernel.c => kernel.cc} | 12 +++++----- usr.sbin/ctld/{login.c => login.cc} | 8 +++---- usr.sbin/ctld/{uclparse.c => uclparse.cc} | 0 9 files changed, 39 insertions(+), 32 deletions(-) diff --git a/usr.sbin/ctld/Makefile b/usr.sbin/ctld/Makefile index ab288c52bc1c..737d09446db8 100644 --- a/usr.sbin/ctld/Makefile +++ b/usr.sbin/ctld/Makefile @@ -5,9 +5,9 @@ CFLAGS+=-I${SRCTOP}/contrib/libucl/include .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.c b/usr.sbin/ctld/conf.cc similarity index 100% rename from usr.sbin/ctld/conf.c rename to usr.sbin/ctld/conf.cc diff --git a/usr.sbin/ctld/conf.h b/usr.sbin/ctld/conf.h index d8f036e67136..6e287ce70436 100644 --- 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 lun_set_size(uint64_t value); bool parse_conf(const char *path); +__END_DECLS + #endif /* !__CONF_H__ */ diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.cc similarity index 98% rename from usr.sbin/ctld/ctld.c rename to usr.sbin/ctld/ctld.cc index cba59c05d4e9..07e262915975 100644 --- a/usr.sbin/ctld/ctld.c +++ b/usr.sbin/ctld/ctld.cc @@ -78,6 +78,9 @@ static struct connection_ops conn_ops = { #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, }; @@ -96,7 +99,7 @@ conf_new(void) { struct conf *conf; - conf = calloc(1, sizeof(*conf)); + conf = reinterpret_cast(calloc(1, sizeof(*conf))); if (conf == NULL) log_err(1, "calloc"); TAILQ_INIT(&conf->conf_luns); @@ -146,7 +149,7 @@ auth_new(struct auth_group *ag) { struct auth *auth; - auth = calloc(1, sizeof(*auth)); + auth = reinterpret_cast(calloc(1, sizeof(*auth))); if (auth == NULL) log_err(1, "calloc"); auth->a_auth_group = ag; @@ -304,7 +307,7 @@ auth_name_new(struct auth_group *ag, const char *name) { struct auth_name *an; - an = calloc(1, sizeof(*an)); + an = reinterpret_cast(calloc(1, sizeof(*an))); if (an == NULL) log_err(1, "calloc"); an->an_auth_group = ag; @@ -362,7 +365,7 @@ auth_portal_new(struct auth_group *ag, const char *portal) char *net, *mask, *str, *tmp; int len, dm, m; - ap = calloc(1, sizeof(*ap)); + ap = reinterpret_cast(calloc(1, sizeof(*ap))); if (ap == NULL) log_err(1, "calloc"); ap->ap_auth_group = ag; @@ -495,7 +498,7 @@ auth_group_new(struct conf *conf, const char *name) } } - ag = calloc(1, sizeof(*ag)); + ag = reinterpret_cast(calloc(1, sizeof(*ag))); if (ag == NULL) log_err(1, "calloc"); if (name != NULL) @@ -548,7 +551,7 @@ portal_new(struct portal_group *pg) { struct portal *portal; - portal = calloc(1, sizeof(*portal)); + portal = reinterpret_cast(calloc(1, sizeof(*portal))); if (portal == NULL) log_err(1, "calloc"); TAILQ_INIT(&portal->p_targets); @@ -579,7 +582,7 @@ portal_group_new(struct conf *conf, const char *name) return (NULL); } - pg = calloc(1, sizeof(*pg)); + pg = reinterpret_cast(calloc(1, sizeof(*pg))); if (pg == NULL) log_err(1, "calloc"); pg->pg_name = checked_strdup(name); @@ -712,7 +715,7 @@ isns_new(struct conf *conf, const char *addr) { struct isns *isns; - isns = calloc(1, sizeof(*isns)); + isns = reinterpret_cast(calloc(1, sizeof(*isns))); if (isns == NULL) log_err(1, "calloc"); isns->i_conf = conf; @@ -974,7 +977,7 @@ pport_new(struct kports *kports, const char *name, uint32_t ctl_port) { struct pport *pp; - pp = calloc(1, sizeof(*pp)); + pp = reinterpret_cast(calloc(1, sizeof(*pp))); if (pp == NULL) log_err(1, "calloc"); pp->pp_kports = kports; @@ -1033,7 +1036,7 @@ port_new(struct conf *conf, struct target *target, struct portal_group *pg) free(name); return (NULL); } - port = calloc(1, sizeof(*port)); + port = reinterpret_cast(calloc(1, sizeof(*port))); if (port == NULL) log_err(1, "calloc"); port->p_conf = conf; @@ -1078,7 +1081,7 @@ port_new_ioctl(struct conf *conf, struct kports *kports, struct target *target, free(name); return (NULL); } - port = calloc(1, sizeof(*port)); + port = reinterpret_cast(calloc(1, sizeof(*port))); if (port == NULL) log_err(1, "calloc"); port->p_conf = conf; @@ -1107,7 +1110,7 @@ port_new_pp(struct conf *conf, struct target *target, struct pport *pp) free(name); return (NULL); } - port = calloc(1, sizeof(*port)); + port = reinterpret_cast(calloc(1, sizeof(*port))); if (port == NULL) log_err(1, "calloc"); port->p_conf = conf; @@ -1188,7 +1191,7 @@ target_new(struct conf *conf, const char *name) if (valid_iscsi_name(name, log_warnx) == false) { return (NULL); } - targ = calloc(1, sizeof(*targ)); + targ = reinterpret_cast(calloc(1, sizeof(*targ))); if (targ == NULL) log_err(1, "calloc"); targ->t_name = checked_strdup(name); @@ -1246,7 +1249,7 @@ lun_new(struct conf *conf, const char *name) return (NULL); } - lun = calloc(1, sizeof(*lun)); + lun = reinterpret_cast(calloc(1, sizeof(*lun))); if (lun == NULL) log_err(1, "calloc"); lun->l_conf = conf; @@ -1366,7 +1369,7 @@ connection_new(struct portal *portal, int fd, const char *host, { struct ctld_connection *conn; - conn = calloc(1, sizeof(*conn)); + conn = reinterpret_cast(calloc(1, sizeof(*conn))); if (conn == NULL) log_err(1, "calloc"); connection_init(&conn->conn, &conn_ops, proxy_mode); @@ -2255,7 +2258,7 @@ found: switch (kev.filter) { case EVFILT_READ: - portal = kev.udata; + portal = reinterpret_cast(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 similarity index 100% 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 similarity index 96% rename from usr.sbin/ctld/isns.c rename to usr.sbin/ctld/isns.cc index 12aacbdef2b2..d25b70628d15 100644 --- a/usr.sbin/ctld/isns.c +++ b/usr.sbin/ctld/isns.cc @@ -49,14 +49,14 @@ isns_req_alloc(void) { struct isns_req *req; - req = calloc(1, sizeof(struct isns_req)); + req = reinterpret_cast(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(calloc(1, req->ir_buflen)); if (req->ir_buf == NULL) { free(req); log_err(1, "calloc"); @@ -102,7 +102,7 @@ isns_req_getspace(struct isns_req *req, uint32_t len) log_err(1, "realloc"); return (1); } - req->ir_buf = newbuf; + req->ir_buf = reinterpret_cast(newbuf); req->ir_buflen = newlen; return (0); } diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.cc similarity index 98% rename from usr.sbin/ctld/kernel.c rename to usr.sbin/ctld/kernel.cc index 206819bdb899..cda84872e269 100644 --- a/usr.sbin/ctld/kernel.c +++ b/usr.sbin/ctld/kernel.cc @@ -171,7 +171,7 @@ cctl_start_element(void *user_data, const char *name, const char **attr) log_errx(1, "%s: improper lun element nesting", __func__); - cur_lun = calloc(1, sizeof(*cur_lun)); + cur_lun = reinterpret_cast(calloc(1, sizeof(*cur_lun))); if (cur_lun == NULL) log_err(1, "%s: cannot allocate %zd bytes", __func__, sizeof(*cur_lun)); @@ -288,7 +288,7 @@ cctl_start_pelement(void *user_data, const char *name, const char **attr) log_errx(1, "%s: improper port element nesting (%s)", __func__, name); - cur_port = calloc(1, sizeof(*cur_port)); + cur_port = reinterpret_cast(calloc(1, sizeof(*cur_port))); if (cur_port == NULL) log_err(1, "%s: cannot allocate %zd bytes", __func__, sizeof(*cur_port)); @@ -423,7 +423,7 @@ conf_new_from_kernel(struct kports *kports) str = NULL; len = 4096; retry: - str = realloc(str, len); + str = reinterpret_cast(realloc(str, len)); if (str == NULL) log_err(1, "realloc"); @@ -472,7 +472,7 @@ retry: str = NULL; len = 4096; retry_port: - str = realloc(str, len); + str = reinterpret_cast(realloc(str, len)); if (str == NULL) log_err(1, "realloc"); @@ -692,13 +692,13 @@ kernel_lun_add(struct lun *lun) 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 similarity index 99% rename from usr.sbin/ctld/login.c rename to usr.sbin/ctld/login.cc index 8833779c825f..84d329964ada 100644 --- 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 @@ login_new_response(struct pdu *request) } 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 similarity index 100% rename from usr.sbin/ctld/uclparse.c rename to usr.sbin/ctld/uclparse.cc