View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0023042 | Open CASCADE | OCCT:Foundation Classes | public | 2012-03-28 12:19 | 2013-12-19 13:56 |
Reporter | kgv | Assigned To | |||
Priority | normal | Severity | minor | ||
Status | closed | Resolution | fixed | ||
Product Version | 6.5.2 | ||||
Target Version | 6.7.0 | Fixed in Version | 6.7.0 | ||
Summary | 0023042: Potential mistakes in (s)printf usage | ||||
Description | There are some warning related to (s)printf usage. This is a known problem caused by fact that (s)printf functions has different format options on different platforms and appear mostly for integer types other than 'int' (long, size_t, int64_t etc.). src/OSD/OSD_MAllocHook.cxx: In static member function 'static Standard_Boolean OSD_MAllocHook::LogFileHandler::MakeReport(const char*, const char*, Standard_Boolean)': src/OSD/OSD_MAllocHook.cxx:362: warning: format '%10d' expects type 'int', but argument 3 has type 'long unsigned int' src/OSD/OSD_MAllocHook.cxx:362: warning: unknown conversion type character 'I' in format src/OSD/OSD_MAllocHook.cxx:362: warning: too many arguments for format src/OSD/OSD_MAllocHook.cxx:376: warning: unknown conversion type character 'I' in format src/OSD/OSD_MAllocHook.cxx:376: warning: too many arguments for format src/OSD/OSD_MAllocHook.cxx: In member function 'virtual void OSD_MAllocHook::LogFileHandler::AllocEvent(size_t, long int)': src/OSD/OSD_MAllocHook.cxx:393: warning: format '%10u' expects type 'unsigned int', but argument 4 has type 'size_t' src/OSD/OSD_MAllocHook.cxx: In member function 'virtual void OSD_MAllocHook::LogFileHandler::FreeEvent(void*, size_t, long int)': src/OSD/OSD_MAllocHook.cxx:415: warning: format '%10u' expects type 'unsigned int', but argument 4 has type 'size_t' src/OSD/OSD_MAllocHook.cxx: In member function 'Standard_Boolean OSD_MAllocHook::CollectBySize::MakeReport(const char*)': src/OSD/OSD_MAllocHook.cxx:497: warning: unknown conversion type character 'I' in format src/OSD/OSD_MAllocHook.cxx:497: warning: too many arguments for format src/OSD/OSD_MAllocHook.cxx:506: warning: unknown conversion type character 'I' in format src/OSD/OSD_MAllocHook.cxx:506: warning: too many arguments for format src/NCollection/NCollection_BaseAllocator.cxx: In static member function 'static void NCollection_BaseAllocator::PrintMemUsageStatistics()': src/NCollection/NCollection_BaseAllocator.cxx:276: warning: format '%12d' expects type 'int', but argument 3 has type 'long unsigned int' src/NCollection/NCollection_BaseAllocator.cxx:276: warning: format '%12d' expects type 'int', but argument 6 has type 'Standard_Size' src/NCollection/NCollection_BaseAllocator.cxx:276: warning: format '%12d' expects type 'int', but argument 7 has type 'Standard_Size' src/NCollection/NCollection_BaseAllocator.cxx:281: warning: format '%12d' expects type 'int', but argument 6 has type 'Standard_Size' src/NCollection/NCollection_BaseAllocator.cxx:281: warning: format '%12d' expects type 'int', but argument 7 has type 'Standard_Size' src/NCollection/NCollection_BaseAllocator.cxx:285: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int' src/NCollection/NCollection_BaseAllocator.cxx:288: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int' src/NCollection/NCollection_IncAllocator.cxx: In function 'void IncAllocator_PrintAlive()': src/NCollection/NCollection_IncAllocator.cxx:165: warning: format '%-8d' expects type 'int', but argument 3 has type 'Standard_Size' src/NCollection/NCollection_HeapAllocator.cxx: In member function 'virtual void* NCollection_HeapAllocator::Allocate(Standard_Size)': src/NCollection/NCollection_HeapAllocator.cxx:41: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int' src/IFSelect/IFSelect_SessionPilot.cxx: In member function 'IFSelect_ReturnStatus IFSelect_SessionPilot::ReadScript(const char*)': src/IFSelect/IFSelect_SessionPilot.cxx:242: warning: format not a string literal and no format arguments src/VrmlData/VrmlData_Scene.cxx: In function 'void dumpNode(Standard_OStream&, const Handle_VrmlData_Node&, const TCollection_AsciiString&)': src/VrmlData/VrmlData_Scene.cxx:1136: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int' src/VrmlData/VrmlData_Scene.cxx:1136: warning: format '%d' expects type 'int', but argument 4 has type 'long unsigned int' src/VrmlData/VrmlData_Scene.cxx:1145: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int' src/VrmlData/VrmlData_Scene.cxx:1145: warning: format '%d' expects type 'int', but argument 4 has type 'long unsigned int' src/BOPTest/BOPTest_LowCommands.cxx: In function 'void PrintState(Draw_Interpretor&, const TopAbs_State&)': src/BOPTest/BOPTest_LowCommands.cxx:735: warning: format not a string literal and no format arguments src/BOPTest/BOPTest_LowCommands.cxx:738: warning: format not a string literal and no format arguments src/BOPTest/BOPTest_LowCommands.cxx:741: warning: format not a string literal and no format arguments src/BOPTest/BOPTest_LowCommands.cxx:744: warning: format not a string literal and no format arguments src/BOPTest/BOPTest_LowCommands.cxx:747: warning: format not a string literal and no format arguments src/QABugs/QABugs_3.cxx: In function 'Standard_Integer coordload(Draw_Interpretor&, Standard_Integer, const char**)': src/QABugs/QABugs_3.cxx:1440: warning: format '%20c' expects type 'char*', but argument 3 has type 'char (*)[30]' src/QABugs/QABugs_3.cxx:1440: warning: format '%20c' expects type 'char*', but argument 4 has type 'char (*)[30]' src/QABugs/QABugs_3.cxx:1448: warning: format '%20c' expects type 'char*', but argument 3 has type 'char (*)[30]' src/QABugs/QABugs_3.cxx:1448: warning: format '%20c' expects type 'char*', but argument 4 has type 'char (*)[30]' src/QABugs/QABugs_11.cxx: In function 'Standard_Integer OCC299bug(Draw_Interpretor&, Standard_Integer, const char**)': src/QABugs/QABugs_11.cxx:934: warning: format not a string literal and no format arguments src/QABugs/QABugs_11.cxx:937: warning: format not a string literal and no format arguments src/QABugs/QABugs_11.cxx:940: warning: format not a string literal and no format arguments src/QABugs/QABugs_11.cxx:943: warning: format not a string literal and no format arguments src/QABugs/QABugs_11.cxx:946: warning: format not a string literal and no format arguments | ||||
Tags | No tags attached. | ||||
Test case number | Not needed | ||||
|
Dear kgv, Fix is implemented into branch CR23042. Please, review. |
|
Dear kgv, I've made some fixes in current branch. Please, review. |
|
Patch is ready for testing in CR23042_1 branch. |
|
Kirill, as a side note, I did not get completely your point in replacing fprintfs by streams, to me the previous code was simpler and nicer. Note that as far as I can see, your changes affected width of the fields in output -- would not it be a problem for someone? Nevertheless, I agree that C++ streams are better in that they are exception safe, so let it be. Another note: please avoid changing formatting and names of existing variables even when they do not meet 'default' OCCT style, e.g. in BOPTest_LowCommands.cxx / bclassify(): usage of simple names for command line arguments (n / a, argc / argv) was de-facto standard for decades, it is better not to break this. |
|
Dear BugMaster, Branch CR23042_1 (and products from GIT master) was compiled on Linux and Windows platforms and tested. SHA-1: 6839f33720ba6c9f8af5d2b05f36bc1cebe9efbe Number of compiler warnings: occt component : Linux: 2 (2 on master) Windows: 7 (7 on master) products component : Linux: 0 (0 on master) Windows: 63 (63 on master) Regressions: No regressions Improvements: No improvements Testing cases: Not needed Testing on Linux: Total MEMORY difference: 364951520 / 365009856 Total CPU difference: 45274.36000000066 / 44730.12000000092 Testing on Windows: Total MEMORY difference: 425488680 / 425517236 Total CPU difference: 40953.1875 / 41691.875 There are not differences in images found by testdiff. |
occt: master 64531d9c 2013-07-12 08:25:44
|
0023042: Potential mistakes in (s)printf usage Use PRIuPTR macros for Standard_Size values in printf. Use STL streams instead of printf when reasonable. |
Affected Issues 0023042 |
|
mod - src/BOPTest/BOPTest_LowCommands.cxx | Diff File | ||
mod - src/IFSelect/IFSelect_SessionPilot.cxx | Diff File | ||
mod - src/NCollection/NCollection_BaseAllocator.cxx | Diff File | ||
mod - src/NCollection/NCollection_HeapAllocator.cxx | Diff File | ||
mod - src/NCollection/NCollection_IncAllocator.cxx | Diff File | ||
mod - src/NCollection/NCollection_IncAllocator.hxx | Diff File | ||
mod - src/OSD/OSD_MAllocHook.cxx | Diff File | ||
mod - src/OSD/OSD_MAllocHook.hxx | Diff File | ||
mod - src/QABugs/QABugs_11.cxx | Diff File | ||
mod - src/QABugs/QABugs_3.cxx | Diff File | ||
mod - src/Standard/Standard_TypeDef.hxx | Diff File | ||
mod - src/VrmlData/VrmlData_Scene.cxx | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-03-28 12:19 | kgv | New Issue | |
2012-03-28 12:19 | kgv | Assigned To | => abv |
2012-05-04 12:48 |
|
Assigned To | abv => dbv |
2012-05-04 12:48 |
|
Status | new => assigned |
2012-10-26 17:58 |
|
Assigned To | dbv => ilv |
2012-10-26 19:10 |
|
Assigned To | ilv => dbv |
2012-10-26 19:10 |
|
Target Version | => 6.6.0 |
2013-03-02 09:54 |
|
Assigned To | dbv => oan |
2013-03-02 09:54 |
|
Assigned To | oan => omy |
2013-03-06 11:22 |
|
Note Added: 0023601 | |
2013-03-06 11:22 |
|
Assigned To | omy => kgv |
2013-03-06 11:22 |
|
Status | assigned => resolved |
2013-03-06 17:10 | kgv | Assigned To | kgv => omy |
2013-03-06 17:10 | kgv | Status | resolved => assigned |
2013-03-11 17:16 |
|
Note Added: 0023646 | |
2013-03-11 17:16 |
|
Assigned To | omy => kgv |
2013-03-11 17:16 |
|
Status | assigned => resolved |
2013-04-12 10:31 |
|
Target Version | 6.6.0 => 6.7.0 |
2013-07-07 20:01 | kgv | Note Added: 0024980 | |
2013-07-07 20:01 | kgv | Assigned To | kgv => bugmaster |
2013-07-07 20:01 | kgv | Status | resolved => reviewed |
2013-07-08 08:31 |
|
Note Added: 0024981 | |
2013-07-08 12:14 | apn | Assigned To | bugmaster => apn |
2013-07-08 17:52 | apn | Note Added: 0024989 | |
2013-07-08 17:53 | apn | Test case number | => Not needed |
2013-07-08 17:53 | apn | Assigned To | apn => bugmaster |
2013-07-08 17:53 | apn | Status | reviewed => tested |
2013-07-12 18:08 |
|
Changeset attached | => occt master 64531d9c |
2013-07-12 18:09 |
|
Assigned To | bugmaster => omy |
2013-07-12 18:09 |
|
Status | tested => verified |
2013-07-12 18:09 |
|
Resolution | open => fixed |
2013-12-19 13:53 | bugmaster | Status | verified => closed |
2013-12-19 13:56 | bugmaster | Fixed in Version | => 6.7.0 |