in reply to XS: SvOK ? SvPV_nolen : NULL
Provided that you don't want to be warned when the argument is undef, your code is correct.