[Rpm-maint] [rpm-software-management/rpm] Convert variable length arrays to C++ strings and vectors (PR #4113)

Panu Matilainen notifications at github.com
Wed Feb 25 07:05:59 UTC 2026


@pmatilai commented on this pull request.



> @@ -18,21 +20,16 @@ int rpmvercmp(const char * a, const char * b)
     /* easy comparison to see if versions are identical */
     if (rstreq(a, b)) return 0;
 
-    char oldch1, oldch2;
-    char abuf[strlen(a)+1], bbuf[strlen(b)+1];
-    char *str1 = abuf, *str2 = bbuf;
-    char * one, * two;
+    std::string abuf(a);
+    std::string bbuf(b);
+    char *str1 = abuf.data(), *str2 = bbuf.data();

They point to the same piece of course, but the difference is that .c_str() returns a const pointer. So .data() is the only choice if you need to modify the contents through a raw pointer. So basically .data() is a "Danger, Will Robinson" sign.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/4113#discussion_r2851256941
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/4113/review/3852315120 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20260224/1392a17e/attachment.htm>


More information about the Rpm-maint mailing list