Yes, my initial thought was to define 2048 and re-use it. I added in the define in case we use something other than 2048 in the future.
I am okay with either one of the approaches. I can send out a new patch with - #define WMI_QUERY_ARRAY_SIZE set to 2048. We can do an incremental for checking the output of wcscat_s/wcscpy_s. However, I noticed that the application would crash instead of returning an errno_t. When the size was large it gave an access violation and when it was small it just crashed with an error finding null pointer. Thanks, Sairam On 1/26/17, 10:57 PM, "Alin Serdean" <[email protected]> wrote: >Thanks for catching this! > >It slipped my mind when I wrote the code. > >Mind adding a define for the number of element instead and passing that in? >i.e. >#define WMI_QUERY 2048 > wchar_t internal_port_query[WMI_QUERY] = L"SELECT * from " > L"Msvm_EthernetPortAllocationSettingData WHERE ElementName = \"" ; >.... >wcscat_s(internal_port_query, WMI_QUERY, wide_name); >instead? >(I am using for both delete/create and maybe we want to increase its size) > >Also another thing that I forgot is to check the output of wcscat_s/wcscpy_s. >In only managed to check it once in 'get_str_value' :(. > >Should I send an incremental? > >Thanks, >Alin. > >> -----Original Message----- >> From: [email protected] [mailto:ovs-dev- >> [email protected]] On Behalf Of Sairam Venugopal >> Sent: Friday, January 27, 2017 7:58 AM >> To: [email protected] >> Subject: [ovs-dev] [PATCH] Windows: Fix wmi.c to use count of wchar_t >> instead of sizeof >> >> wcscat_s and wcscpy_s requires number of elements as argument. wchar_t >> uses 2 bytes for storage and using sizeof(internal_port_query) causes access >> violation error on Windows 2012 R2 (64 bit). This patch introduces a >> count_of() function to return the count of the wchar_t array. >> >> Signed-off-by: Sairam Venugopal <[email protected]> >> Reported-by: Sairam Venugopal <[email protected]> >> Reported-at: openvswitch/ovs-issues#121 >> --- >> lib/wmi.c | 34 +++++++++++++++++++--------------- >> 1 file changed, 19 insertions(+), 15 deletions(-) >> _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
