Genericity of nondegenerate geodesics with general boundary conditions