[ovs-dev] [PATCH 2/4] util: A generic function to convert error to string for windows.

Gurucharan Shetty shettyg at nicira.com
Tue Jan 28 17:57:44 UTC 2014


On Fri, Jan 17, 2014 at 1:35 PM, Ben Pfaff <blp at nicira.com> wrote:
> On Fri, Jan 17, 2014 at 01:22:39PM -0800, Gurucharan Shetty wrote:
>> On Fri, Jan 17, 2014 at 1:07 PM, Ben Pfaff <blp at nicira.com> wrote:
>> > On Fri, Jan 17, 2014 at 12:26:21PM -0800, Gurucharan Shetty wrote:
>> >> More users will be added in an upcoming commit.
>> >>
>> >> Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
>> >
>> > Why doesn't ovs_lasterror_to_string() take an appropriate type?  (Why
>> > does the only user need a cast to pass the argument?)
>> I don'y see any reason for the cast. I suppose you mean
>> ovs_lasterror_to_string() could have taken LPVOID as an argument,
>> correct?
>
> I mean, FormatMessage() must be storing a pointer to a character
> string in msg_buf, because msg_buf is used as a char * in the call to
> VLOG_ERR, so I would expect that the appropriate type for msg_buf is
> 'char *' and that, thus, ovs_lasterror_to_string()'s parameter should
> have type 'char **'.
Okay.
>
> (To me, it looks totally weird to define msg_buf as any kind of void
> pointer, because FormatMessage() doesn't expect that, hence the need
> for a cast.)
>
It is counter intuitive (or bad api), but FormatMessage() expects a
char ** to be cast as char * and sent to it when
FORMAT_MESSAGE_ALLOCATE_BUFFER is set in its first argument.



More information about the dev mailing list