In addition, start ordering header file includes to be in more consistent order: system header files, src/utils, src/*, same directory as the *.c file.
Check the return code in some (but not yet all) places where the functions from ms_funcs.c are used.