I know by Bochner's theorem one has : If $(M,g)$ is a compact , oriented Riemannian manifold and $\text{Ric}_g<0$ , then $\text{Ric}_g(X,X)=0$ iff $X=0$ for any killing vector field $X$ .
Now I want to verify whether the following statement is true : If $(M,g)$ is a Riemannian manifold with $\text{Ric}_g>0$ and $u:M\to\mathbb{R}$ is a smooth function , then $\text{Ric}_g(\nabla_gu,\nabla_gu)=0$ iff $\nabla_gu=0$ .
The strict negative definite case requires $M$ to be compact for sure . I am not sure whether strict positive definite case will drop the compactness . Also the killing field is now replaced by the gradient . In all those possible cases , will the result still hold true ? Whatever modification can we do in the strict positive definite case so that it holds true ?
Any help is appreciated .