Maybe it is worth to move s and common_setting inside if (copyfrom_setting == CF_PROTOCOL_UNDEFINED).
Then those will be evaluated only if copyfrom_setting is not provided by the user.