String Formatting Warning


ROOT Version: 6.24/04
Platform: lxplus/ RHEL 7
Compiler: c++ (GCC) 4.8.5 20150623


I am trying to automatically include histogram names in the legend by using GetName functionality for histograms and I am facing this. It does show to include β€œ%s” but how do I use it? I am confused since I am not directly using a string.

pltnomsys.C:232:49: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
l1->AddEntry(hnom_mXbin5_nb1_tt,TString::Format(hnom_mXbin5_nb1_tt->GetName()));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pltnomsys.C:232:49: note: treat the string as an argument to avoid this
l1->AddEntry(hnom_mXbin5_nb1_tt,TString::Format(hnom_mXbin5_nb1_tt->GetName()));

GetName() already returns the correct type, so there’s no need to use Format there.
https://root.cern/doc/master/classTNamed.html#af3c77cf4d3ce2c64e4797e9fcb4560d9

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.