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

Re: [libvirt] [PATCHv2 01/13] virbuf: fix const-correctness



On 10/17/2011 10:36 PM, Eric Blake wrote:
On 10/17/2011 05:20 AM, Hai Dong Li wrote:
On 09/30/2011 12:22 AM, Eric Blake wrote:
Although the compiler wasn't complaining (since it was the pointer,
rather than what was being pointed to, that was actually const), it
looks quite suspicious to call a function with an argument labeled
const when the nature of the pointer (virBufferPtr) is hidden behind
a typedef. Dropping const makes the function declarations easier
to read.


+++ b/src/util/buf.c
@@ -39,7 +39,7 @@ struct _virBuffer {
* freeing the content and setting the error flag.
*/
static void
-virBufferSetError(const virBufferPtr buf)
+virBufferSetError(virBufferPtr buf)
{
VIR_FREE(buf->content);
buf->size = 0;
@@ -113,7 +113,7 @@ virBufferAdd(const virBufferPtr buf, const char
*str, int len)

Maybe a typo here?The virBufferPtr still remains const, but the
declaration of this function in the buf.h shows this const is removed, too.

No. Rather, this is an artifact of git diff. When showing the context line for a hunk, it uses the context from the pre-patch file (where the 'const' was still present), even though the hunk itself applies to the post-patch version without 'const'. Basically, I never worry about the @@ lines - they are there as hints for where to apply the patch, and not a definitive part of the patch itself.

Okay, forget the context line.
What I wanted to say is that the function virBufferAdd in the buf.c still has the const before the virBufferPtr while the declaration of this function in buf.h has const removed, after applying this patch.


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