The easiest way is to ask from a point of not understanding and ask their opinion. ItsIt's no good to say "your code sucks", itsit's quite another to say "erm, I saw this and I really can't understand what itsit's doing, or why itsit's doing it. What do you think?" or similar - you could say what your concern is and ask them to explain it to you, or ask them just if you are right.
This way, you bring them into being part of the solution and typically will realiserealize the problem and fix it themselves (or you can offer to do it for them).
I'm sure you've written code like that yourself, you just don't see it until someone points it out and you have a d'oh moment. Treat such code not as a huge, glaring error but as just another slight cock up that we all make now and then and you'll be good.