Re: [PATCH 2/7] util: buffer: Use 'size_t' for buffer size variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/1/19 2:59 AM, Peter Krempa wrote:
On Sat, Mar 30, 2019 at 12:21:51 -0400, Laine Stump wrote:
On 3/29/19 9:33 AM, Peter Krempa wrote:
Use size_t for all sizes. The '*' modifier unfortunately does require an
int so a temporary variable is necessary in the tests.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
   src/util/virbuffer.c | 2 +-
   src/util/virbuffer.h | 6 +++---
   tests/virbuftest.c   | 4 +++-
   3 files changed, 7 insertions(+), 5 deletions(-)
[...]

@@ -29,7 +30,8 @@ static int testBufInfiniteLoop(const void *data)
        * which was the case after the above addchar at the time of the bug.
        * This test is a bit fragile, since it relies on virBuffer internals.
        */
-    if (virAsprintf(&addstr, "%*s", buf->size - buf->use - 1, "a") < 0)
+    len = buf->size - buf->use - 1;
+    if (virAsprintf(&addstr, "%*s", len, "a") < 0)

If you really wanted to avoid the temporary int (which you've implied you
don't like in the commit message), you could just do a typecast in the arg
list.
That looke worse.


Agreed. It just sounded like maybe you regretted putting in the int, so I was offering you an out :-)


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux