QVM memset and memcpy return NULL, but should return first argument (like strncpy). However, fixing this will cause mods that use the return to be incompatible with vanilla q3 and past ioq3 versions.
strncpy was returning incorrect non-zero value in vanilla q3 and fixed in ioq3, so might be similar issue of mod depending on it not working on vanilla q3.
Should they be fixed or left as is?
Issue is in CL_CgameSystemCalls, CL_UISystemCalls, and SV_GameSystemCalls.
Instead of changing the behaviour of syscalls -101 and -102, perhaps it would be better to change their names to trap_memset0 and trap_memcpy0, and change bg_lib.h like this?
// *_syscalls.asm --------------------------------------------------
// Like ISO C memset, but returns NULL instead of dest
equ trap_memset0 -101
// Like ISO C memcpy, but returns NULL instead of dest
equ trap_memcpy0 -102
// bg_lib.h --------------------------------------------------------
void *trap_memset0( void *dest, int c, size_t count );
void *trap_memcpy0( void *dest, const void *src, size_t count );
#define memset(dest, c, count) (trap_memset0(dest, c, count), dest)
#define memcpy(dest, src, count) (trap_memcpy0(dest, src, count), dest)
That way, any VMs compiled with an old bg_lib.h (mods are expected to supply their own copy, right?) will get the result they expects, and any VMs compiled with a new bg_lib.h (notably ioquake3's own game/cgame/ui) will get the result *they* expect, consistent with what they'd get as native code.
Created attachment 3348 [details] Fix QVM memset and memcpy return values