In this case, yes, that fixes it.
More in general, though, you can turn of warnings on block level, not unit level.
That prevents you from turning off a specific warning for a whole unit, That is also in the wiki. After all, it can be a situation where the warning would be correct and you overlooked it.
If you know the variable is initialized, use it only in the block that triggers the warning.