From nobody Wed Feb 11 14:24:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1487863863205475.13871372103574; Thu, 23 Feb 2017 07:31:03 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NFRp2M019772; Thu, 23 Feb 2017 10:27:51 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1NFR4F3000775 for ; Thu, 23 Feb 2017 10:27:04 -0500 Received: from antique-work.brq.redhat.com (dhcp129-175.brq.redhat.com [10.34.129.175]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NFR1Wf018328 for ; Thu, 23 Feb 2017 10:27:04 -0500 From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 16:26:57 +0100 Message-Id: <933dd443b10c7a6a071f19bac608e90ccdc5c7aa.1487863437.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/5] util: use VIR_STRCAT instead of strcat X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- cfg.mk | 14 ++++++++------ src/storage/storage_backend_logical.c | 6 +++--- src/test/test_driver.c | 2 +- src/util/vircgroup.c | 4 +--- src/xen/xend_internal.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cfg.mk b/cfg.mk index 22c655eac6..6646509206 100644 --- a/cfg.mk +++ b/cfg.mk @@ -390,6 +390,11 @@ sc_prohibit_strdup: halt=3D'use VIR_STRDUP, not strdup' \ $(_sc_search_regexp) =20 +sc_prohibit_strcat: + @prohibit=3D'\ *\(' \ + halt=3D'use VIR_STRCAT, not strcat' \ + $(_sc_search_regexp) + # Prefer virSetUIDGID. sc_prohibit_setuid: @prohibit=3D'\ *\(' \ @@ -994,12 +999,6 @@ sc_prohibit_not_streq: halt=3D'Use STRNEQ instead of !STREQ and STREQ instead of !STRNEQ' \ $(_sc_search_regexp) =20 -sc_prohibit_verbose_strcat: - @prohibit=3D'strncat\([^,]*,\s+([^,]*),\s+strlen\(\1\)\)' \ - in_vc_files=3D'\.[ch]$$' \ - halt=3D'Use strcat(a, b) instead of strncat(a, b, strlen(b))' \ - $(_sc_search_regexp) - # Ensure that each .c file containing a "main" function also # calls virGettextInitialize sc_gettext_init: @@ -1134,6 +1133,9 @@ exclude_file_name_regexp--sc_prohibit_asprintf =3D \ exclude_file_name_regexp--sc_prohibit_strdup =3D \ ^(docs/|examples/|src/util/virstring\.c|tests/vir(netserverclient|cgroup= )mock.c$$) =20 +exclude_file_name_regexp--sc_prohibit_strcat =3D \ + ^(docs/|src/util/virstring\.c|tests/virstringtest\.c)$$ + exclude_file_name_regexp--sc_prohibit_close =3D \ (\.p[yl]$$|\.spec\.in$$|^docs/|^(src/util/virfile\.c|src/libvirt-stream\= .c|tests/vir.+mock\.c)$$) =20 diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 756c62e908..5e006a980a 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -201,11 +201,11 @@ virStorageBackendLogicalParseVolExtents(virStorageVol= DefPtr vol, /* Allocate space for 'nextents' regex_unit strings plus a comma for e= ach */ if (VIR_ALLOC_N(regex, nextents * (strlen(regex_unit) + 1) + 1) < 0) goto cleanup; - strcat(regex, regex_unit); + VIR_STRCAT_INPLACE(regex, regex_unit); for (i =3D 1; i < nextents; i++) { /* "," is the separator of "devices" field */ - strcat(regex, ","); - strcat(regex, regex_unit); + VIR_STRCAT_INPLACE(regex, ","); + VIR_STRCAT_INPLACE(regex, regex_unit); } =20 if (VIR_ALLOC(reg) < 0) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 5fef3f10b9..be887ec1bb 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -699,7 +699,7 @@ static char *testBuildFilename(const char *relativeTo, VIR_FREE(absFile); return NULL; } - strcat(absFile, filename); + ignore_value(VIR_STRCAT_INPLACE(absFile, filename)); return absFile; } else { ignore_value(VIR_STRDUP(ret, filename)); diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 5aa1db5b14..e8210ca6eb 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1299,10 +1299,8 @@ virCgroupSetPartitionSuffix(const char *path, char *= *res) */ if (STRNEQ(tokens[i], "") && !strchr(tokens[i], '.')) { - if (VIR_REALLOC_N(tokens[i], - strlen(tokens[i]) + strlen(".partition") + 1= ) < 0) + if (VIR_STRCAT(tokens[i], ".partition") < 0) goto cleanup; - strcat(tokens[i], ".partition"); } =20 if (virCgroupPartitionEscape(&(tokens[i])) < 0) diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 605c3cdccf..1f9d4c6959 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -1824,7 +1824,7 @@ xenDaemonDomainPinVcpu(virConnectPtr conn, for (i =3D 0; i < maplen; i++) for (j =3D 0; j < 8; j++) if (cpumap[i] & (1 << j)) { snprintf(buf, sizeof(buf), "%zu,", (8 * i) + j); - strcat(mapstr, buf); + VIR_STRCAT_INPLACE(mapstr, buf); } mapstr[strlen(mapstr) - 1] =3D 0; =20 --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list