On 12/11/18 11:10 PM, Jonathan McDougall wrote: > Line 1324, nonce in MHD_queue_auth_fail_response2(). >
Ack, will fix. > Since you're willing to use C99 features, here's what I'm thinking. In > w32/common/MHD_config.h, you want an exception for the clang toolset, > which does support VLAs: > > /* MS VC doesn't support VLAs, but the clang toolset does */ > #ifndef __clang__ > #define __STDC_NO_VLA__ 1 > #endif > > and change your macro to something like this: > > #if __STDC_NO_VLA__ > #define MAKE_VLA(TYPE, NAME, REAL_SIZE, MAX_SIZE) \ > TYPE NAME[(MAX_SIZE)]; \ > if ((REAL_SIZE) > (MAX_SIZE)) \ > mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big"); > #else > #define MAKE_VLA(TYPE, NAME, REAL_SIZE, MAX_SIZE) \ > TYPE NAME[(REAL_SIZE)]; > #endif > > Use it like this: > > MAKE_VLA(uint8_t, dig, da->digest_size, MAX_DIGEST); This won't work. Sometimes we have two VLA variables, and with this you violate the c89 constraint that variables must be declared at the beginning of a code block (and the 'if' statement is now in the middle of the list of variable declarations). > There are a few definitions that have a complicated size, with a > combination of the digest size and NONCE_STD_LEN, I'd pay special > attention to those, they might not work with my macro. I don't see why not. Anyway, I was specifically avoiding your construction style because of the c89 issue with not mixing statements and variable declarations. Did you try mine with VS, or is your statement about this not being a 'constant' based on being picky about reading the standard? Because with my macro, the compiler _could_ certainly figure out that there is only one possible length of this array and generate the 'efficient' non-VLA logic. > I would again urge you to reconsider going the VLA route and change this > all back to constant sizes for all compilers. Oh, but the 'old' version was only supporting one hash function, the new one is hash function agnostic, and different hash functions have different sizes. So we would suddenly drastically increase stack requirements for MD5.
signature.asc
Description: OpenPGP digital signature
