A note on the linearity of real-valued functions with respect to suitable metrics